54dbc5173d
Change-Id: I08f52e5dab16f5d176a909b29952718891f406d5
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
// Copyright (C) 2020 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
import Vuex from 'vuex';
|
|
|
|
import { makeProjectsModule, PROJECTS_MUTATIONS } from '@/store/modules/projects';
|
|
import { makeUsersModule, USER_MUTATIONS } from '@/store/modules/users';
|
|
import { Project } from '@/types/projects';
|
|
import { User } from '@/types/users';
|
|
import { ProjectOwning } from '@/utils/projectOwning';
|
|
import { createLocalVue } from '@vue/test-utils';
|
|
|
|
import { ProjectsApiMock } from '../mock/api/projects';
|
|
import { UsersApiMock } from '../mock/api/users';
|
|
|
|
const usersApi = new UsersApiMock();
|
|
const usersModule = makeUsersModule(usersApi);
|
|
const projectsApi = new ProjectsApiMock();
|
|
const projectsModule = makeProjectsModule(projectsApi);
|
|
|
|
const localVue = createLocalVue();
|
|
localVue.use(Vuex);
|
|
|
|
const store = new Vuex.Store({ modules: { usersModule, projectsModule }});
|
|
|
|
describe('projectOwning', () => {
|
|
it('user has no project', () => {
|
|
const user = new User('ownerId');
|
|
store.commit(USER_MUTATIONS.SET_USER, user);
|
|
|
|
expect(new ProjectOwning(store).userHasOwnProject()).toBeFalsy();
|
|
});
|
|
|
|
it('user has project', () => {
|
|
const project = new Project('id', 'test', 'test', 'test', 'ownerId', true);
|
|
store.commit(PROJECTS_MUTATIONS.ADD, project);
|
|
|
|
expect(new ProjectOwning(store).userHasOwnProject()).toBeTruthy();
|
|
});
|
|
});
|