Skip to content
Snippets Groups Projects

Fix clicking disabled clipboard button toolip

Merged Luke "Jared" Bennett requested to merge disable-clicking-disabled-clipboard-button into master
All threads resolved!
1 file
+ 27
4
Compare changes
  • Side-by-side
  • Inline
@@ -83,25 +83,48 @@ describe('Blob viewer', () => {
@@ -83,25 +83,48 @@ describe('Blob viewer', () => {
});
});
describe('copy blob button', () => {
describe('copy blob button', () => {
 
let copyButton;
 
 
beforeEach(() => {
 
copyButton = document.querySelector('.js-copy-blob-source-btn');
 
});
 
it('disabled on load', () => {
it('disabled on load', () => {
expect(
expect(
document.querySelector('.js-copy-blob-source-btn').classList.contains('disabled'),
copyButton.classList.contains('disabled'),
).toBeTruthy();
).toBeTruthy();
});
});
it('has tooltip when disabled', () => {
it('has tooltip when disabled', () => {
expect(
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');
).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) => {
it('enables after switching to simple view', (done) => {
document.querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]').click();
document.querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]').click();
setTimeout(() => {
setTimeout(() => {
expect($.ajax).toHaveBeenCalled();
expect($.ajax).toHaveBeenCalled();
expect(
expect(
document.querySelector('.js-copy-blob-source-btn').classList.contains('disabled'),
copyButton.classList.contains('disabled'),
).toBeFalsy();
).toBeFalsy();
done();
done();
@@ -115,7 +138,7 @@ describe('Blob viewer', () => {
@@ -115,7 +138,7 @@ describe('Blob viewer', () => {
expect($.ajax).toHaveBeenCalled();
expect($.ajax).toHaveBeenCalled();
expect(
expect(
document.querySelector('.js-copy-blob-source-btn').getAttribute('data-original-title'),
copyButton.getAttribute('data-original-title'),
).toBe('Copy source to clipboard');
).toBe('Copy source to clipboard');
done();
done();
Loading