diff options
author | Nick Thomas <nick@gitlab.com> | 2018-12-15 15:21:54 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-12-15 15:21:54 +0300 |
commit | 8d2e1b724bd515c5977090d722b915f374218eb3 (patch) | |
tree | 3e52f0b8994fa274326dacb1a942ab265462d73e /spec/javascripts | |
parent | c027101d34ebdbd935e2c2b35827323c110b3654 (diff) | |
parent | 9f9eb03f3d8247438523a9fee3a83967fecd8114 (diff) |
Merge branch '54786-mr-empty-file-display' into 'master'
Display empty files properly on MR diffs
Closes #54786
See merge request gitlab-org/gitlab-ce!23671
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/diffs/components/diff_content_spec.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/javascripts/diffs/components/diff_content_spec.js b/spec/javascripts/diffs/components/diff_content_spec.js index d688560a260..9e158327a77 100644 --- a/spec/javascripts/diffs/components/diff_content_spec.js +++ b/spec/javascripts/diffs/components/diff_content_spec.js @@ -50,6 +50,45 @@ describe('DiffContent', () => { }); }); + describe('empty files', () => { + beforeEach(() => { + vm.diffFile.empty = true; + vm.diffFile.highlighted_diff_lines = []; + vm.diffFile.parallel_diff_lines = []; + }); + + it('should render a message', done => { + vm.$nextTick(() => { + const block = vm.$el.querySelector('.diff-viewer .nothing-here-block'); + + expect(block).not.toBe(null); + expect(block.textContent.trim()).toContain('Empty file'); + + done(); + }); + }); + + it('should not render multiple messages', done => { + vm.diffFile.mode_changed = true; + vm.diffFile.b_mode = '100755'; + vm.diffFile.viewer.name = 'mode_changed'; + + vm.$nextTick(() => { + expect(vm.$el.querySelectorAll('.nothing-here-block').length).toBe(1); + + done(); + }); + }); + + it('should not render diff table', done => { + vm.$nextTick(() => { + expect(vm.$el.querySelector('table')).toBe(null); + + done(); + }); + }); + }); + describe('Non-Text diffs', () => { beforeEach(() => { vm.diffFile.viewer.name = 'image'; |