Fixed failing JS tests

This commit is contained in:
Phil Hughes 2017-04-26 10:09:07 +01:00 committed by Douwe Maan
parent dc4726f0a7
commit 95658fb62a
2 changed files with 8 additions and 4 deletions

View file

@ -1,4 +1,3 @@
/* eslint-disable no-new */
/* global Flash */ /* global Flash */
export default class BlobViewer { export default class BlobViewer {
constructor() { constructor() {
@ -76,6 +75,7 @@ export default class BlobViewer {
url, url,
dataType: 'JSON', dataType: 'JSON',
}) })
.fail(() => new Flash('Error loading source view'))
.done((data) => { .done((data) => {
viewer.innerHTML = data.html; viewer.innerHTML = data.html;
$(viewer).syntaxHighlight(); $(viewer).syntaxHighlight();

View file

@ -1,7 +1,7 @@
/* eslint-disable no-new */ /* eslint-disable no-new */
import BlobViewer from '~/blob/viewer/index'; import BlobViewer from '~/blob/viewer/index';
describe('Blob viewer', () => { fdescribe('Blob viewer', () => {
preloadFixtures('blob/show.html.raw'); preloadFixtures('blob/show.html.raw');
beforeEach(() => { beforeEach(() => {
@ -73,6 +73,10 @@ describe('Blob viewer', () => {
document.querySelector('.blob-viewer[data-type="simple"]').getAttribute('data-loaded'), document.querySelector('.blob-viewer[data-type="simple"]').getAttribute('data-loaded'),
).toBe('true'); ).toBe('true');
done();
})
.catch(() => {
fail();
done(); done();
}); });
}); });
@ -87,7 +91,7 @@ describe('Blob viewer', () => {
it('has tooltip when disabled', () => { it('has tooltip when disabled', () => {
expect( expect(
document.querySelector('.js-copy-blob-source-btn').getAttribute('data-original-title'), document.querySelector('.js-copy-blob-source-btn').getAttribute('data-original-title'),
).toBe('Switch to the source view to copy the source to the clipboard'); ).toBe('Switch to the source to copy it to the clipboard');
}); });
it('enables after switching to simple view', (done) => { it('enables after switching to simple view', (done) => {
@ -111,7 +115,7 @@ describe('Blob viewer', () => {
expect( expect(
document.querySelector('.js-copy-blob-source-btn').getAttribute('data-original-title'), document.querySelector('.js-copy-blob-source-btn').getAttribute('data-original-title'),
).toBe('Copy to clipboard'); ).toBe('Copy source to clipboard');
done(); done();
}); });