Remove favicon check from mrWidgetOptions spec

The method that actually creates the favicon is already unit tested, I
would have loved to mock it out, but ist is not possible without using
rewire. So I decided we just check that the favicon href is changed and
use that as a proxy for calling `setFaviconOverlay`
This commit is contained in:
Lukas Eipert 2019-01-23 10:59:49 +01:00
parent 85002b6a7f
commit 7db474ff78
No known key found for this signature in database
GPG key ID: 148BEA37CB35B2AC

View file

@ -5,7 +5,7 @@ import notify from '~/lib/utils/notify';
import { stateKey } from '~/vue_merge_request_widget/stores/state_maps';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
import mockData from './mock_data';
import { faviconDataUrl, overlayDataUrl, faviconWithOverlayDataUrl } from '../lib/utils/mock_data';
import { faviconDataUrl, overlayDataUrl } from '../lib/utils/mock_data';
const returnPromise = data =>
new Promise(resolve => {
@ -340,17 +340,27 @@ describe('mrWidgetOptions', () => {
vm.mr.ciStatusFaviconPath = overlayDataUrl;
vm.setFaviconHelper()
.then(() => {
expect(faviconElement.getAttribute('href')).toEqual(faviconWithOverlayDataUrl);
/*
It would be better if we'd could mock commonUtils.setFaviconURL
with a spy and test that it was called. We are doing the following
tests as a proxy to show that the function has been called
*/
expect(faviconElement.getAttribute('href')).not.toEqual(null);
expect(faviconElement.getAttribute('href')).not.toEqual(overlayDataUrl);
expect(faviconElement.getAttribute('href')).not.toEqual(faviconDataUrl);
done();
})
.catch(done.fail);
});
it('should not call setFavicon when there is no ciStatusFaviconPath', () => {
it('should not call setFavicon when there is no ciStatusFaviconPath', done => {
vm.mr.ciStatusFaviconPath = null;
vm.setFaviconHelper();
expect(faviconElement.getAttribute('href')).toEqual(null);
vm.setFaviconHelper()
.then(() => {
expect(faviconElement.getAttribute('href')).toEqual(null);
done();
})
.catch(done.fail);
});
});