Commit 95658fb6 authored by Phil Hughes's avatar Phil Hughes Committed by Douwe Maan

Fixed failing JS tests

parent dc4726f0
/* 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 { ...@@ -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();
......
/* 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', () => { ...@@ -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', () => { ...@@ -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', () => { ...@@ -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();
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment