diff options
author | Phil Hughes <me@iamphill.com> | 2018-10-16 12:05:19 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-10-23 09:12:37 +0100 |
commit | 9fd5a78d8bb8be1146574fdda5920bc2ec72620a (patch) | |
tree | 68c538495b5c84caa8ddfb5d52622c2293ed4429 | |
parent | d95465db2cf79c0c95584e23c005a14302fc2c88 (diff) | |
download | gitlab-ce-9fd5a78d8bb8be1146574fdda5920bc2ec72620a.tar.gz |
Fixed failing specs
Added tests to file row truncated text computed prop
-rw-r--r-- | spec/javascripts/diffs/components/tree_list_spec.js | 10 | ||||
-rw-r--r-- | spec/javascripts/diffs/store/utils_spec.js | 6 | ||||
-rw-r--r-- | spec/javascripts/vue_shared/components/file_row_spec.js | 36 |
3 files changed, 40 insertions, 12 deletions
diff --git a/spec/javascripts/diffs/components/tree_list_spec.js b/spec/javascripts/diffs/components/tree_list_spec.js index 86e2b03292d..fc94d0bab5b 100644 --- a/spec/javascripts/diffs/components/tree_list_spec.js +++ b/spec/javascripts/diffs/components/tree_list_spec.js @@ -53,8 +53,7 @@ describe('Diffs tree list component', () => { fileHash: 'test', key: 'index.js', name: 'index.js', - path: 'index.js', - truncatedPath: '../index.js', + path: 'app/index.js', removedLines: 0, tempFile: true, type: 'blob', @@ -105,7 +104,7 @@ describe('Diffs tree list component', () => { vm.$el.querySelector('.file-row').click(); - expect(vm.$store.dispatch).toHaveBeenCalledWith('diffs/scrollToFile', 'index.js'); + expect(vm.$store.dispatch).toHaveBeenCalledWith('diffs/scrollToFile', 'app/index.js'); }); it('renders as file list when renderTreeList is false', done => { @@ -122,7 +121,7 @@ describe('Diffs tree list component', () => { vm.renderTreeList = false; vm.$nextTick(() => { - expect(vm.$el.querySelector('.file-row').textContent).toContain('../index.js'); + expect(vm.$el.querySelector('.file-row').textContent).toContain('app/index.js'); done(); }); @@ -144,8 +143,7 @@ describe('Diffs tree list component', () => { const blurEvent = new Event('blur'); vm.focusSearch = true; - vm - .$nextTick() + vm.$nextTick() .then(() => { vm.$el.querySelector('.form-control').dispatchEvent(blurEvent); }) diff --git a/spec/javascripts/diffs/store/utils_spec.js b/spec/javascripts/diffs/store/utils_spec.js index 6a0a69967fa..f49dee3696d 100644 --- a/spec/javascripts/diffs/store/utils_spec.js +++ b/spec/javascripts/diffs/store/utils_spec.js @@ -470,7 +470,6 @@ describe('DiffsStoreUtils', () => { { key: 'app', path: 'app', - truncatedPath: 'app', name: 'app', type: 'tree', tree: [ @@ -482,7 +481,6 @@ describe('DiffsStoreUtils', () => { key: 'app/index.js', name: 'index.js', path: 'app/index.js', - truncatedPath: 'app/index.js', removedLines: 10, tempFile: false, type: 'blob', @@ -491,7 +489,6 @@ describe('DiffsStoreUtils', () => { { key: 'app/test', path: 'app/test', - truncatedPath: 'app/test', name: 'test', type: 'tree', opened: true, @@ -504,7 +501,6 @@ describe('DiffsStoreUtils', () => { key: 'app/test/index.js', name: 'index.js', path: 'app/test/index.js', - truncatedPath: 'app/test/index.js', removedLines: 0, tempFile: true, type: 'blob', @@ -518,7 +514,6 @@ describe('DiffsStoreUtils', () => { key: 'app/test/filepathneedstruncating.js', name: 'filepathneedstruncating.js', path: 'app/test/filepathneedstruncating.js', - truncatedPath: '...est/filepathneedstruncating.js', removedLines: 0, tempFile: true, type: 'blob', @@ -532,7 +527,6 @@ describe('DiffsStoreUtils', () => { { key: 'package.json', path: 'package.json', - truncatedPath: 'package.json', name: 'package.json', type: 'blob', changed: true, diff --git a/spec/javascripts/vue_shared/components/file_row_spec.js b/spec/javascripts/vue_shared/components/file_row_spec.js index 9914c0b70f3..67752c1c455 100644 --- a/spec/javascripts/vue_shared/components/file_row_spec.js +++ b/spec/javascripts/vue_shared/components/file_row_spec.js @@ -71,4 +71,40 @@ describe('RepoFile', () => { expect(vm.$el.querySelector('.file-row-name').style.marginLeft).toBe('32px'); }); + + describe('outputText', () => { + beforeEach(done => { + createComponent({ + file: { + ...file(), + path: 'app/assets/index.js', + }, + level: 0, + }); + + vm.displayTextKey = 'path'; + + vm.$nextTick(done); + }); + + it('returns text if truncateStart is 0', done => { + vm.truncateStart = 0; + + vm.$nextTick(() => { + expect(vm.outputText).toBe('app/assets/index.js'); + + done(); + }); + }); + + it('returns text truncated at start', done => { + vm.truncateStart = 5; + + vm.$nextTick(() => { + expect(vm.outputText).toBe('...ssets/index.js'); + + done(); + }); + }); + }); }); |