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:
parent
85002b6a7f
commit
7db474ff78
1 changed files with 16 additions and 6 deletions
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue