Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-07-20 15:26:25 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-20 15:26:25 +0300
commita09983ae35713f5a2bbb100981116d31ce99826e (patch)
tree2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/frontend/diffs/components/app_spec.js
parent18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff)
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/frontend/diffs/components/app_spec.js')
-rw-r--r--spec/frontend/diffs/components/app_spec.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/frontend/diffs/components/app_spec.js b/spec/frontend/diffs/components/app_spec.js
index 57e3a93c6f4..b7f03f35dfb 100644
--- a/spec/frontend/diffs/components/app_spec.js
+++ b/spec/frontend/diffs/components/app_spec.js
@@ -56,6 +56,7 @@ describe('diffs/components/app', () => {
changesEmptyStateIllustration: '',
dismissEndpoint: '',
showSuggestPopover: true,
+ viewDiffsFileByFile: false,
...props,
},
provide,
@@ -829,4 +830,58 @@ describe('diffs/components/app', () => {
expect(toggleShowTreeList).not.toHaveBeenCalled();
});
});
+
+ describe('file-by-file', () => {
+ it('renders a single diff', () => {
+ createComponent({ viewDiffsFileByFile: true }, ({ state }) => {
+ state.diffs.diffFiles.push({ file_hash: '123' });
+ state.diffs.diffFiles.push({ file_hash: '312' });
+ });
+
+ expect(wrapper.findAll(DiffFile).length).toBe(1);
+ });
+
+ describe('pagination', () => {
+ it('sets previous button as disabled', () => {
+ createComponent({ viewDiffsFileByFile: true }, ({ state }) => {
+ state.diffs.diffFiles.push({ file_hash: '123' }, { file_hash: '312' });
+ });
+
+ expect(wrapper.find('[data-testid="singleFilePrevious"]').props('disabled')).toBe(true);
+ expect(wrapper.find('[data-testid="singleFileNext"]').props('disabled')).toBe(false);
+ });
+
+ it('sets next button as disabled', () => {
+ createComponent({ viewDiffsFileByFile: true }, ({ state }) => {
+ state.diffs.diffFiles.push({ file_hash: '123' }, { file_hash: '312' });
+ state.diffs.currentDiffFileId = '312';
+ });
+
+ expect(wrapper.find('[data-testid="singleFilePrevious"]').props('disabled')).toBe(false);
+ expect(wrapper.find('[data-testid="singleFileNext"]').props('disabled')).toBe(true);
+ });
+
+ it.each`
+ currentDiffFileId | button | index
+ ${'123'} | ${'singleFileNext'} | ${1}
+ ${'312'} | ${'singleFilePrevious'} | ${0}
+ `(
+ 'it calls navigateToDiffFileIndex with $index when $button is clicked',
+ ({ currentDiffFileId, button, index }) => {
+ createComponent({ viewDiffsFileByFile: true }, ({ state }) => {
+ state.diffs.diffFiles.push({ file_hash: '123' }, { file_hash: '312' });
+ state.diffs.currentDiffFileId = currentDiffFileId;
+ });
+
+ jest.spyOn(wrapper.vm, 'navigateToDiffFileIndex');
+
+ wrapper.find(`[data-testid="${button}"]`).vm.$emit('click');
+
+ return wrapper.vm.$nextTick().then(() => {
+ expect(wrapper.vm.navigateToDiffFileIndex).toHaveBeenCalledWith(index);
+ });
+ },
+ );
+ });
+ });
});