diff --git a/ee/spec/javascripts/operations/components/dashboard/dashboard_spec.js b/ee/spec/javascripts/operations/components/dashboard/dashboard_spec.js index b8080e4e94798d420393cffe56d362b24b1b1d6f..09fdffc5c7c6779a8c53493cb96093c4459b8da3 100644 --- a/ee/spec/javascripts/operations/components/dashboard/dashboard_spec.js +++ b/ee/spec/javascripts/operations/components/dashboard/dashboard_spec.js @@ -1,8 +1,5 @@ import Vue from 'vue'; -import MockAdapter from 'axios-mock-adapter'; -import axios from '~/lib/utils/axios_utils'; import store from 'ee/operations/store/index'; -import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; import Dashboard from 'ee/operations/components/dashboard/dashboard.vue'; import ProjectSearch from 'ee/operations/components/dashboard/project_search.vue'; import DashboardProject from 'ee/operations/components/dashboard/project.vue'; @@ -14,29 +11,28 @@ describe('dashboard component', () => { const ProjectSearchComponent = Vue.extend(ProjectSearch); const DashboardProjectComponent = Vue.extend(DashboardProject); const projectTokens = mockProjectData(1); - const mockListPath = 'mock-listPath'; const mount = () => - mountComponentWithStore(DashboardComponent, { + new DashboardComponent({ store, - props: { + propsData: { addPath: 'mock-addPath', - listPath: mockListPath, + listPath: 'mock-listPath', emptyDashboardSvgPath: '/assets/illustrations/operations-dashboard_empty.svg', emptyDashboardHelpPath: '/help/user/operations_dashboard/index.html', }, - }); + methods: { + fetchProjects: () => {}, + }, + }).$mount(); let vm; - let mockAxios; beforeEach(() => { vm = mount(); - mockAxios = new MockAdapter(axios); }); afterEach(() => { vm.$destroy(); clearState(store); - mockAxios.restore(); }); it('renders dashboard title', () => { @@ -57,7 +53,7 @@ describe('dashboard component', () => { }); it('calls action to add projects on click if projectTokens have been added', () => { - const spy = spyOn(vm, 'addProjectsToDashboard'); + const spy = spyOn(vm, 'addProjectsToDashboard').and.stub(); vm.$store.state.projectTokens = projectTokens; button.click(); @@ -65,7 +61,7 @@ describe('dashboard component', () => { }); it('does not call action to add projects on click when projectTokens is empty', () => { - const spy = spyOn(vm, 'addProjectsToDashboard'); + const spy = spyOn(vm, 'addProjectsToDashboard').and.stub(); button.click(); expect(spy).not.toHaveBeenCalled(); @@ -102,16 +98,14 @@ describe('dashboard component', () => { describe('empty state', () => { beforeEach(() => { - mockAxios.onGet(mockListPath).replyOnce(200, { data: [] }); + store.state.projects = []; vm = mount(); }); it('renders empty state svg after requesting projects with no results', () => { - const svgSrc = vm.$el - .querySelector('.js-empty-state-svg') - .src.slice(-mockText.EMPTY_SVG_SOURCE.length); + const svgSrc = vm.$el.querySelector('.js-empty-state-svg').src; - expect(svgSrc).toBe(mockText.EMPTY_SVG_SOURCE); + expect(svgSrc).toMatch(mockText.EMPTY_SVG_SOURCE); }); it('renders title', () => {