2020-05-05 16:55:26 +01:00
|
|
|
// Copyright (C) 2020 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
import Vuex from 'vuex';
|
|
|
|
|
2020-09-09 19:25:59 +01:00
|
|
|
import ProjectDropdown from '@/components/header/projectsDropdown/ProjectDropdown.vue';
|
2020-05-05 16:55:26 +01:00
|
|
|
|
2020-09-03 15:58:29 +01:00
|
|
|
import { appStateModule } from '@/store/modules/appState';
|
2020-05-05 16:55:26 +01:00
|
|
|
import { makeProjectsModule, PROJECTS_MUTATIONS } from '@/store/modules/projects';
|
|
|
|
import { Project } from '@/types/projects';
|
|
|
|
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
|
|
|
|
2020-09-03 15:58:29 +01:00
|
|
|
import { ProjectsApiMock } from '../mock/api/projects';
|
2020-05-05 16:55:26 +01:00
|
|
|
|
|
|
|
const localVue = createLocalVue();
|
|
|
|
localVue.use(Vuex);
|
|
|
|
|
|
|
|
const projectsApi = new ProjectsApiMock();
|
|
|
|
const projectsModule = makeProjectsModule(projectsApi);
|
|
|
|
const project1 = new Project('testId1', 'testName1', '');
|
|
|
|
const project2 = new Project('testId2', 'testName2', '');
|
|
|
|
|
2020-09-03 15:58:29 +01:00
|
|
|
const store = new Vuex.Store({ modules: { projectsModule, appStateModule }});
|
2020-05-05 16:55:26 +01:00
|
|
|
|
2020-08-20 20:38:17 +01:00
|
|
|
describe('ProjectDropdown', () => {
|
2020-05-05 16:55:26 +01:00
|
|
|
it('renders correctly', () => {
|
|
|
|
store.commit(PROJECTS_MUTATIONS.SET_PROJECTS, [project1, project2]);
|
|
|
|
store.commit(PROJECTS_MUTATIONS.SELECT_PROJECT, project1.id);
|
|
|
|
|
2020-08-20 20:38:17 +01:00
|
|
|
const wrapper = shallowMount(ProjectDropdown, {
|
2020-05-05 16:55:26 +01:00
|
|
|
store,
|
|
|
|
localVue,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|