storj/web/satellite/tests/unit/project/CreateProject.spec.ts
Egon Elbre 8620532a05 web/satellite: bump dependencies
This contains also multiple fixes to make it work.
The following is a non-exhaustive list.

When @Prop default value is a callback, then it is called
instead of set verbatim. This means, when you want a default
value to be a callback, then it needs to be `default: () => () => X`.

jest does not yet properly support WebWorkers, hence the code introduces
an indirection to provide the worker URL.

This in turn required removing the global "store" dependency from
the tests. As a consequence the new NotificatorPlugin takes store
as a dependency. And many of the tests are adjusted to not import
store directly.

Moved StoreModule definition to avoid initializing the global store.

Some of the router code was moved into store. We can later figure out
how to structure it better and move it back.

bip39 needs explicit fallbacks for some of the dependencies.

Fixes to timer mocking. jest supports it natively.

Remove sinon dependency. jest provides all the functionality we need.

Change-Id: I7af3599390c63ce9f99dbd0b1e0870e9f8ca994d
2022-05-04 15:02:01 +00:00

45 lines
1.2 KiB
TypeScript

// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
import Vuex from 'vuex';
import CreateProject from '@/components/project/CreateProject.vue';
import { makeProjectsModule } from '@/store/modules/projects';
import { NotificatorPlugin } from '@/utils/plugins/notificator';
import { createLocalVue, mount } from '@vue/test-utils';
import { ProjectsApiMock } from '../mock/api/projects';
const localVue = createLocalVue();
localVue.use(Vuex);
const projectsApi = new ProjectsApiMock();
const projectsModule = makeProjectsModule(projectsApi);
const store = new Vuex.Store({ modules: { projectsModule }});
localVue.use(new NotificatorPlugin(store));
describe('CreateProject.vue', (): void => {
it('renders correctly', (): void => {
const wrapper = mount<CreateProject>(CreateProject, {
store,
localVue,
});
expect(wrapper).toMatchSnapshot();
});
it('renders correctly with project name', async (): Promise<void> => {
const wrapper = mount<CreateProject>(CreateProject, {
store,
localVue,
});
await wrapper.vm.setProjectName('testName');
expect(wrapper.findAll('.disabled').length).toBe(0);
});
});