diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-24 09:07:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-24 09:07:07 +0300 |
commit | 12287a65b735d784cda3555d1b261e50b461b29e (patch) | |
tree | e7539b1b3672986a4f41b544f913ee120d623d44 /spec/javascripts/blob | |
parent | 24ed154fa81265f47bcfbecfcb331f82a5faad0d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/javascripts/blob')
-rw-r--r-- | spec/javascripts/blob/viewer/index_spec.js | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/spec/javascripts/blob/viewer/index_spec.js b/spec/javascripts/blob/viewer/index_spec.js index 06c06613887..bbc59632f3c 100644 --- a/spec/javascripts/blob/viewer/index_spec.js +++ b/spec/javascripts/blob/viewer/index_spec.js @@ -11,6 +11,13 @@ describe('Blob viewer', () => { preloadFixtures('snippets/show.html'); + const asyncClick = () => + new Promise(resolve => { + document.querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]').click(); + + setTimeout(resolve); + }); + beforeEach(() => { mock = new MockAdapter(axios); @@ -66,19 +73,12 @@ describe('Blob viewer', () => { }); it('doesnt reload file if already loaded', done => { - const asyncClick = () => - new Promise(resolve => { - document.querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]').click(); - - setTimeout(resolve); - }); - asyncClick() .then(() => asyncClick()) .then(() => { - expect( - document.querySelector('.blob-viewer[data-type="simple"]').getAttribute('data-loaded'), - ).toBe('true'); + expect(document.querySelector('.blob-viewer[data-type="simple"]').dataset.loaded).toBe( + 'true', + ); done(); }) @@ -100,9 +100,7 @@ describe('Blob viewer', () => { }); it('has tooltip when disabled', () => { - expect(copyButton.getAttribute('data-original-title')).toBe( - 'Switch to the source to copy the file contents', - ); + expect(copyButton.dataset.title).toBe('Switch to the source to copy the file contents'); }); it('is blurred when clicked and disabled', () => { @@ -136,7 +134,7 @@ describe('Blob viewer', () => { document.querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]').click(); setTimeout(() => { - expect(copyButton.getAttribute('data-original-title')).toBe('Copy file contents'); + expect(copyButton.dataset.title).toBe('Copy file contents'); done(); }); @@ -177,4 +175,27 @@ describe('Blob viewer', () => { expect(axios.get.calls.count()).toBe(1); }); }); + + describe('a URL inside the blob content', () => { + beforeEach(() => { + mock.onGet('http://test.host/snippets/1.json?viewer=simple').reply(200, { + html: + '<div class="js-blob-content"><pre class="code"><code><span class="line" lang="yaml"><span class="c1">To install gitlab-shell you also need a Go compiler version 1.8 or newer. https://golang.org/dl/</span></span></code></pre></div>', + }); + }); + + it('is rendered as a link in simple view', done => { + asyncClick() + .then(() => { + expect(document.querySelector('.blob-viewer[data-type="simple"]').innerHTML).toContain( + '<a href="https://golang.org/dl/">https://golang.org/dl/</a>', + ); + done(); + }) + .catch(() => { + fail(); + done(); + }); + }); + }); }); |