diff options
Diffstat (limited to 'spec/frontend/diffs/components')
-rw-r--r-- | spec/frontend/diffs/components/diff_content_spec.js | 1 | ||||
-rw-r--r-- | spec/frontend/diffs/components/diff_stats_spec.js | 53 | ||||
-rw-r--r-- | spec/frontend/diffs/components/settings_dropdown_spec.js | 1 |
3 files changed, 44 insertions, 11 deletions
diff --git a/spec/frontend/diffs/components/diff_content_spec.js b/spec/frontend/diffs/components/diff_content_spec.js index db4d69f0176..7012889440c 100644 --- a/spec/frontend/diffs/components/diff_content_spec.js +++ b/spec/frontend/diffs/components/diff_content_spec.js @@ -73,6 +73,7 @@ describe('DiffContent', () => { isParallelView: isParallelViewGetterMock, getCommentFormForDiffFile: getCommentFormForDiffFileGetterMock, diffLines: () => () => [...diffFileMockData.parallel_diff_lines], + fileLineCodequality: () => () => [], }, actions: { saveDiffDiscussion: saveDiffDiscussionMock, diff --git a/spec/frontend/diffs/components/diff_stats_spec.js b/spec/frontend/diffs/components/diff_stats_spec.js index 504158fb7fc..4ef1ec55cb0 100644 --- a/spec/frontend/diffs/components/diff_stats_spec.js +++ b/spec/frontend/diffs/components/diff_stats_spec.js @@ -1,6 +1,9 @@ import { GlIcon } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; +import { extendedWrapper } from 'helpers/vue_test_utils_helper'; + import DiffStats from '~/diffs/components/diff_stats.vue'; +import mockDiffFile from '../mock_data/diff_file'; const TEST_ADDED_LINES = 100; const TEST_REMOVED_LINES = 200; @@ -11,13 +14,15 @@ describe('diff_stats', () => { let wrapper; const createComponent = (props = {}) => { - wrapper = shallowMount(DiffStats, { - propsData: { - addedLines: TEST_ADDED_LINES, - removedLines: TEST_REMOVED_LINES, - ...props, - }, - }); + wrapper = extendedWrapper( + shallowMount(DiffStats, { + propsData: { + addedLines: TEST_ADDED_LINES, + removedLines: TEST_REMOVED_LINES, + ...props, + }, + }), + ); }; describe('diff stats group', () => { @@ -38,15 +43,43 @@ describe('diff_stats', () => { }); }); + describe('bytes changes', () => { + let file; + const getBytesContainer = () => wrapper.find('.diff-stats > div:first-child'); + + beforeEach(() => { + file = { + ...mockDiffFile, + viewer: { + ...mockDiffFile.viewer, + name: 'not_diffable', + }, + }; + + createComponent({ diffFile: file }); + }); + + it("renders the bytes changes instead of line changes when the file isn't diffable", () => { + const content = getBytesContainer(); + + expect(content.classes('gl-text-green-600')).toBe(true); + expect(content.text()).toBe('+1.00 KiB (+100%)'); + }); + }); + describe('line changes', () => { - const findFileLine = (name) => wrapper.find(name); + const findFileLine = (name) => wrapper.findByTestId(name); + + beforeEach(() => { + createComponent(); + }); it('shows the amount of lines added', () => { - expect(findFileLine('.js-file-addition-line').text()).toBe(TEST_ADDED_LINES.toString()); + expect(findFileLine('js-file-addition-line').text()).toBe(TEST_ADDED_LINES.toString()); }); it('shows the amount of lines removed', () => { - expect(findFileLine('.js-file-deletion-line').text()).toBe(TEST_REMOVED_LINES.toString()); + expect(findFileLine('js-file-deletion-line').text()).toBe(TEST_REMOVED_LINES.toString()); }); }); diff --git a/spec/frontend/diffs/components/settings_dropdown_spec.js b/spec/frontend/diffs/components/settings_dropdown_spec.js index feac88cb802..43b9c5871a6 100644 --- a/spec/frontend/diffs/components/settings_dropdown_spec.js +++ b/spec/frontend/diffs/components/settings_dropdown_spec.js @@ -142,7 +142,6 @@ describe('Diff settings dropdown component', () => { expect(store.dispatch).toHaveBeenCalledWith('diffs/setShowWhitespace', { showWhitespace: !checked, - pushState: true, }); }); }); |