diff options
Diffstat (limited to 'spec/frontend/diffs/components/diff_file_header_spec.js')
-rw-r--r-- | spec/frontend/diffs/components/diff_file_header_spec.js | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/spec/frontend/diffs/components/diff_file_header_spec.js b/spec/frontend/diffs/components/diff_file_header_spec.js index b16ef8fe6b0..342b4bfcc50 100644 --- a/spec/frontend/diffs/components/diff_file_header_spec.js +++ b/spec/frontend/diffs/components/diff_file_header_spec.js @@ -7,7 +7,7 @@ import { mockTracking, triggerEvent } from 'helpers/tracking_helper'; import DiffFileHeader from '~/diffs/components/diff_file_header.vue'; import { DIFF_FILE_AUTOMATIC_COLLAPSE, DIFF_FILE_MANUAL_COLLAPSE } from '~/diffs/constants'; import { reviewFile } from '~/diffs/store/actions'; -import { SET_MR_FILE_REVIEWS } from '~/diffs/store/mutation_types'; +import { SET_DIFF_FILE_VIEWED, SET_MR_FILE_REVIEWS } from '~/diffs/store/mutation_types'; import { diffViewerModes } from '~/ide/constants'; import { scrollToElement } from '~/lib/utils/common_utils'; import { truncateSha } from '~/lib/utils/text_utility'; @@ -23,6 +23,7 @@ jest.mock('~/lib/utils/common_utils'); const diffFile = Object.freeze( Object.assign(diffDiscussionsMockData.diff_file, { id: '123', + file_hash: 'xyz', file_identifier_hash: 'abc', edit_path: 'link:/to/edit/path', blob: { @@ -58,7 +59,7 @@ describe('DiffFileHeader component', () => { toggleFileDiscussions: jest.fn(), toggleFileDiscussionWrappers: jest.fn(), toggleFullDiff: jest.fn(), - toggleActiveFileByHash: jest.fn(), + setCurrentFileHash: jest.fn(), setFileCollapsedByUser: jest.fn(), reviewFile: jest.fn(), }, @@ -240,18 +241,19 @@ describe('DiffFileHeader component', () => { }); describe('for any file', () => { - const otherModes = Object.keys(diffViewerModes).filter((m) => m !== 'mode_changed'); + const allModes = Object.keys(diffViewerModes).map((m) => [m]); - it('for mode_changed file mode displays mode changes', () => { + it.each(allModes)('for %s file mode displays mode changes', (mode) => { createComponent({ props: { diffFile: { ...diffFile, + mode_changed: true, a_mode: 'old-mode', b_mode: 'new-mode', viewer: { ...diffFile.viewer, - name: diffViewerModes.mode_changed, + name: diffViewerModes[mode], }, }, }, @@ -259,13 +261,14 @@ describe('DiffFileHeader component', () => { expect(findModeChangedLine().text()).toMatch(/old-mode.+new-mode/); }); - it.each(otherModes.map((m) => [m]))( + it.each(allModes.filter((m) => m[0] !== 'mode_changed'))( 'for %s file mode does not display mode changes', (mode) => { createComponent({ props: { diffFile: { ...diffFile, + mode_changed: false, a_mode: 'old-mode', b_mode: 'new-mode', viewer: { @@ -553,7 +556,13 @@ describe('DiffFileHeader component', () => { reviewFile, { file, reviewed: true }, {}, - [{ type: SET_MR_FILE_REVIEWS, payload: { [file.file_identifier_hash]: [file.id] } }], + [ + { type: SET_DIFF_FILE_VIEWED, payload: { id: file.file_hash, seen: true } }, + { + type: SET_MR_FILE_REVIEWS, + payload: { [file.file_identifier_hash]: [file.id, `hash:${file.file_hash}`] }, + }, + ], [], ); }); |