storj/web/satellite/tests/unit/utils/projectOwning.spec.ts
VitaliiShpital 54dbc5173d web/satellite: limits info bar added to billing page, free credit amount changed
Change-Id: I08f52e5dab16f5d176a909b29952718891f406d5
2020-03-16 14:54:46 +00:00

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();
});
});