Skip to content

Commit

Permalink
test coverage improvements for InstructorResponsesViewBase
Browse files Browse the repository at this point in the history
  • Loading branch information
justinsegawa committed Apr 24, 2024
1 parent e738e25 commit aeba215
Showing 1 changed file with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { CommentTableModel } from '../../comment-box/comment-table/comment-table
import { RichTextEditorModule } from '../../rich-text-editor/rich-text-editor.module';
import { TeammatesCommonModule } from '../../teammates-common/teammates-common.module';
import { SingleResponseModule } from '../single-response/single-response.module';
import testEventEmission from '../../../../test-helpers/test-event-emitter';

Check failure on line 24 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

`../../../../test-helpers/test-event-emitter` import should occur before import of `../../../../types/api-request`

Check failure on line 24 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (windows-latest)

`../../../../test-helpers/test-event-emitter` import should occur before import of `../../../../types/api-request`

describe('PerQuestionViewResponsesComponent', () => {
let component: PerQuestionViewResponsesComponent;
Expand Down Expand Up @@ -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; });

Check failure on line 152 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

Trailing spaces not allowed

Check failure on line 152 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (windows-latest)

Trailing spaces not allowed
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; });

Check failure on line 162 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

Trailing spaces not allowed

Check failure on line 162 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (windows-latest)

Trailing spaces not allowed
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; });

Check failure on line 171 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

Trailing spaces not allowed

Check failure on line 171 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (windows-latest)

Trailing spaces not allowed
component.triggerSaveNewCommentEvent('testID3');
expect(emittedID).toBe('testID3');
});

it('triggerModelChangeForSingleResponse: should emit correct instructorCommentTableModel Record to instructorCommentTableModelChange', () => {

Check failure on line 176 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

This line has a length of 144. Maximum allowed is 120

Check failure on line 176 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (windows-latest)

This line has a length of 144. Maximum allowed is 120
let emittedRecord: Record<string, CommentTableModel> | undefined;
testEventEmission(component.instructorCommentTableModelChange, (record) => { emittedRecord = record; });

let testRecord: Record<string, CommentTableModel> = {'testID4': commentTableModel};

Check failure on line 180 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

'testRecord' is never reassigned. Use 'const' instead

Check failure on line 180 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

A space is required after '{'

Check failure on line 180 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

Unnecessarily quoted property 'testID4' found

Check failure on line 180 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

A space is required before '}'

Check failure on line 180 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (windows-latest)

'testRecord' is never reassigned. Use 'const' instead

Check failure on line 180 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (windows-latest)

A space is required after '{'

Check failure on line 180 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (windows-latest)

Unnecessarily quoted property 'testID4' found

Check failure on line 180 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (windows-latest)

A space is required before '}'

component.triggerModelChangeForSingleResponse('testID4', commentTableModel);
expect(emittedRecord).toStrictEqual(testRecord);
});

it('triggerModelChange: should emit correct instructorCommentTableModel Record to triggerModelChange', () => {
let emittedRecord: Record<string, CommentTableModel> | undefined;
testEventEmission(component.instructorCommentTableModelChange, (record) => { emittedRecord = record; });

let testRecord: Record<string, CommentTableModel> = {};

Check failure on line 190 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

'testRecord' is never reassigned. Use 'const' instead

Check failure on line 190 in src/web/app/components/question-responses/per-question-view-responses/per-question-view-responses.component.spec.ts

View workflow job for this annotation

GitHub Actions / lint (windows-latest)

'testRecord' is never reassigned. Use 'const' instead

component.triggerModelChange(testRecord);
expect(emittedRecord).toStrictEqual(testRecord);
});
});

0 comments on commit aeba215

Please sign in to comment.