Skip to content

Commit

Permalink
Attempt to fix flaky my absences report state service spec once more
Browse files Browse the repository at this point in the history
  • Loading branch information
hupf committed Nov 9, 2023
1 parent 79d7416 commit 82af1d4
Showing 1 changed file with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,20 @@ describe("MyAbsencesReportStateService", () => {
let beforeLessonStart: TimetableEntry;
let onLessonStart: TimetableEntry;
let afterLessonStart: TimetableEntry;
let now: Date;

beforeEach(() => {
storageMock = jasmine.createSpyObj("StorageService", ["getPayload"]);

beforeLessonStart = buildTimetableEntry(
1,
subHours(new Date(), 2),
subHours(new Date(), 1),
);
onLessonStart = buildTimetableEntry(
2,
subHours(new Date(), 1),
addHours(new Date(), 1),
);
afterLessonStart = buildTimetableEntry(
3,
addHours(new Date(), 1),
addHours(new Date(), 2),
);
now = new Date();
const oneHourAgo = subHours(now, 1);
const twoHoursAgo = subHours(now, 2);
const oneHourFromNow = addHours(now, 1);
const twoHoursFromNow = addHours(now, 2);

beforeLessonStart = buildTimetableEntry(1, twoHoursAgo, oneHourAgo);
onLessonStart = buildTimetableEntry(2, oneHourAgo, oneHourFromNow);
afterLessonStart = buildTimetableEntry(3, oneHourFromNow, twoHoursFromNow);

TestBed.configureTestingModule(
buildTestModuleMetadata({
Expand Down Expand Up @@ -73,7 +68,7 @@ describe("MyAbsencesReportStateService", () => {
it("should return all entries", fakeAsync(() => {
initializeServiceWithInstance("GymHofwil");

service.setFilter({ dateFrom: new Date(), dateTo: new Date() });
service.setFilter({ dateFrom: now, dateTo: now });
tick(10);

expect(entriesCallback.calls.mostRecent().args[0]).toEqual([
Expand All @@ -88,8 +83,8 @@ describe("MyAbsencesReportStateService", () => {
it("should only return entries starting after lesson start", fakeAsync(() => {
initializeServiceWithInstance("BsTest");

service.setFilter({ dateFrom: new Date(), dateTo: new Date() });
tick(1000);
service.setFilter({ dateFrom: now, dateTo: now });
tick(10);

expect(entriesCallback.calls.mostRecent().args[0]).toEqual([
buildLessonPresenceFromTimetableEntry(afterLessonStart),
Expand Down

0 comments on commit 82af1d4

Please sign in to comment.