diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-05-18 20:53:15 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-05-18 20:53:15 +0000 |
commit | 1f9a9629dbd954520e15e436352316cfdc24d362 (patch) | |
tree | 2279dbb81976d9fd6674823a8f4d3c6ce2b128c9 /spec/javascripts/blob | |
parent | a3eabcc20c422db7032e31397c21dbc6ca3166de (diff) | |
download | gitlab-ce-1f9a9629dbd954520e15e436352316cfdc24d362.tar.gz |
Fix clicking disabled clipboard button toolip
Diffstat (limited to 'spec/javascripts/blob')
-rw-r--r-- | spec/javascripts/blob/viewer/index_spec.js | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/spec/javascripts/blob/viewer/index_spec.js b/spec/javascripts/blob/viewer/index_spec.js index 13f122b68b2..af04e7c1e72 100644 --- a/spec/javascripts/blob/viewer/index_spec.js +++ b/spec/javascripts/blob/viewer/index_spec.js @@ -83,25 +83,48 @@ describe('Blob viewer', () => { }); describe('copy blob button', () => { + let copyButton; + + beforeEach(() => { + copyButton = document.querySelector('.js-copy-blob-source-btn'); + }); + it('disabled on load', () => { expect( - document.querySelector('.js-copy-blob-source-btn').classList.contains('disabled'), + copyButton.classList.contains('disabled'), ).toBeTruthy(); }); it('has tooltip when disabled', () => { expect( - document.querySelector('.js-copy-blob-source-btn').getAttribute('data-original-title'), + copyButton.getAttribute('data-original-title'), ).toBe('Switch to the source to copy it to the clipboard'); }); + it('is blurred when clicked and disabled', () => { + spyOn(copyButton, 'blur'); + + copyButton.click(); + + expect(copyButton.blur).toHaveBeenCalled(); + }); + + it('is not blurred when clicked and not disabled', () => { + spyOn(copyButton, 'blur'); + + copyButton.classList.remove('disabled'); + copyButton.click(); + + expect(copyButton.blur).not.toHaveBeenCalled(); + }); + it('enables after switching to simple view', (done) => { document.querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]').click(); setTimeout(() => { expect($.ajax).toHaveBeenCalled(); expect( - document.querySelector('.js-copy-blob-source-btn').classList.contains('disabled'), + copyButton.classList.contains('disabled'), ).toBeFalsy(); done(); @@ -115,7 +138,7 @@ describe('Blob viewer', () => { expect($.ajax).toHaveBeenCalled(); expect( - document.querySelector('.js-copy-blob-source-btn').getAttribute('data-original-title'), + copyButton.getAttribute('data-original-title'), ).toBe('Copy source to clipboard'); done(); |