Skip to content

Commit

Permalink
improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
coolchock committed Dec 18, 2024
1 parent 556bd55 commit d17d7f8
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,51 @@ describe('ExamParticipationComponent', () => {
});
});

describe('websocket exam rescheduled subscription', () => {
const startDate = dayjs().add(5, 'minutes');
const endDate = dayjs().add(10, 'minutes');
const exam = new Exam();
exam.startDate = dayjs().add(5, 'minutes');
exam.endDate = dayjs().add(10, 'minutes');
const studentExam = { id: 3, workingTime: 420, numberOfExamSessions: 0, exam: exam };

it('should correctly postpone exam', () => {
const newStartDate = startDate.add(10, 'minutes');
const newEndDate = endDate.add(10, 'minutes');

const event = {
newStartDate: newStartDate,
newEndDate: newEndDate,
} as any as ExamLiveEvent;

jest.spyOn(examParticipationLiveEventsService, 'observeNewEventsAsSystem').mockReturnValue(of(event));
const ackSpy = jest.spyOn(examParticipationLiveEventsService, 'acknowledgeEvent');
comp.handleStudentExam(studentExam);

expect(comp.exam.startDate).toStrictEqual(newStartDate);
expect(comp.exam.endDate).toStrictEqual(newEndDate);
expect(ackSpy).toHaveBeenCalledExactlyOnceWith(event, false);
});

it('should correctly bring forward exam', () => {
const newStartDate = startDate.subtract(10, 'minutes');
const newEndDate = endDate.subtract(10, 'minutes');

const event = {
newStartDate: newStartDate,
newEndDate: newEndDate,
} as any as ExamLiveEvent;

jest.spyOn(examParticipationLiveEventsService, 'observeNewEventsAsSystem').mockReturnValue(of(event));
const ackSpy = jest.spyOn(examParticipationLiveEventsService, 'acknowledgeEvent');
comp.handleStudentExam(studentExam);

expect(comp.exam.startDate).toStrictEqual(newStartDate);
expect(comp.exam.endDate).toStrictEqual(newEndDate);
expect(ackSpy).toHaveBeenCalledExactlyOnceWith(event, false);
});
});

describe('websocket problem statement update subscription', () => {
beforeEach(() => {
comp.studentExam = new StudentExam();
Expand Down

0 comments on commit d17d7f8

Please sign in to comment.