summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-05-18 18:07:08 +0100
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-05-18 18:07:08 +0100
commit255aed3a317c4c70ec74e1471eb50721435efa24 (patch)
tree7f92a2f57572c313345e05869b97d624a5e7cb67
parentbe411be7980003430973051caa7a63d3da1884ea (diff)
downloadgitlab-ce-disable-clicking-disabled-clipboard-button.tar.gz
Added spec for bluring disabled copy buttondisable-clicking-disabled-clipboard-button
-rw-r--r--spec/javascripts/blob/viewer/index_spec.js31
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();