diff --git a/src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts b/src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts index 89824377254..9bf8d587623 100644 --- a/src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts +++ b/src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts @@ -8,6 +8,7 @@ import { import SpyInstance = jest.SpyInstance; import { PerQuestionViewResponsesComponent } from './per-question-view-responses.component'; import { FeedbackResponsesService } from '../../../../services/feedback-responses.service'; +import testEventEmission from '../../../../test-helpers/test-event-emitter'; import { CommentVisibilityType, FeedbackParticipantType, FeedbackQuestionType, NumberOfEntitiesToGiveFeedbackToSetting, @@ -143,4 +144,52 @@ describe('PerQuestionViewResponsesComponent', () => { expect(JSON.stringify(component.responsesToShow[0])) .toBe(JSON.stringify(responseOutput)); }); + + it('triggerDeleteCommentEvent: should emit correct responseID and index to deleteCommentEvent', () => { + let emittedID: string | undefined; + let emittedIndex: number | undefined; + testEventEmission(component.deleteCommentEvent, (val) => { emittedID = val.responseId; emittedIndex = val.index; }); + + component.triggerDeleteCommentEvent('testID', 5); + expect(emittedID).toBe('testID'); + expect(emittedIndex).toBe(5); + }); + + it('triggerUpdateCommentEvent: should emit correct responseID and index to updateCommentEvent', () => { + let emittedID: string | undefined; + let emittedIndex: number | undefined; + testEventEmission(component.updateCommentEvent, (val) => { emittedID = val.responseId; emittedIndex = val.index; }); + + component.triggerUpdateCommentEvent('testID2', 6); + expect(emittedID).toBe('testID2'); + expect(emittedIndex).toBe(6); + }); + + it('triggerSaveNewCommentEvent: should emit correct responseID to saveNewCommentEvent', () => { + let emittedID: string | undefined; + testEventEmission(component.saveNewCommentEvent, (responseId) => { emittedID = responseId; }); + + component.triggerSaveNewCommentEvent('testID3'); + expect(emittedID).toBe('testID3'); + }); + + it('triggerModelChangeForSingleResponse: should emit correct Record to instructorCommentTableModelChange', () => { + let emittedRecord: Record | undefined; + testEventEmission(component.instructorCommentTableModelChange, (record) => { emittedRecord = record; }); + + const testRecord: Record = { responseId: commentTableModel }; + + component.triggerModelChangeForSingleResponse('responseId', commentTableModel); + expect(emittedRecord).toEqual(testRecord); + }); + + it('triggerModelChange: should emit correct instructorCommentTableModel Record to triggerModelChange', () => { + let emittedRecord: Record | undefined; + testEventEmission(component.instructorCommentTableModelChange, (record) => { emittedRecord = record; }); + + const testRecord: Record = {}; + + component.triggerModelChange(testRecord); + expect(emittedRecord).toEqual(testRecord); + }); });