From 7db474ff78a86389c7fd4aea0ffd64a293add0cc Mon Sep 17 00:00:00 2001 From: Lukas Eipert Date: Wed, 23 Jan 2019 10:59:49 +0100 Subject: 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` --- .../vue_mr_widget/mr_widget_options_spec.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'spec/javascripts') diff --git a/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js b/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js index 99b80df766a..c7be2079476 100644 --- a/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js +++ b/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js @@ -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); }); }); -- cgit v1.2.1 From 0152cb0dd413b30b9473741959fac92ac1742a78 Mon Sep 17 00:00:00 2001 From: Lukas Eipert Date: Wed, 23 Jan 2019 12:39:46 +0100 Subject: Fix discussion counter spec mock data To me it seems like the mock data does not match the actual data anymore. I checked the actual data and to me it seems like the resolved property actually should live in the overall discussion object. --- spec/javascripts/notes/components/discussion_counter_spec.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'spec/javascripts') diff --git a/spec/javascripts/notes/components/discussion_counter_spec.js b/spec/javascripts/notes/components/discussion_counter_spec.js index d09bc5037ef..fecc0d604b1 100644 --- a/spec/javascripts/notes/components/discussion_counter_spec.js +++ b/spec/javascripts/notes/components/discussion_counter_spec.js @@ -33,11 +33,13 @@ describe('DiscussionCounter component', () => { ...discussionMock, id: discussionMock.id, notes: [{ ...discussionMock.notes[0], resolvable: true, resolved: true }], + resolved: true, }, { ...discussionMock, id: discussionMock.id + 1, notes: [{ ...discussionMock.notes[0], resolvable: true, resolved: false }], + resolved: false, }, ]; const firstDiscussionId = discussionMock.id + 1; -- cgit v1.2.1