mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
* Add hydration functions and logout route * Add tests for hydration * Add collections nav * Structure collections module, add overview route * Fix failing tests * Add test for use-navigation * Add tests for collections-navigation * Add tests for collections-overview * Fix export for use-navigation composition * Update tests
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
import { useCollectionsStore } from './stores/collections/';
|
|
import { hydrated, hydrate, dehydrate } from './hydrate';
|
|
|
|
import Vue from 'vue';
|
|
import VueCompositionAPI from '@vue/composition-api';
|
|
|
|
describe('Hydration', () => {
|
|
beforeAll(() => {
|
|
Vue.use(VueCompositionAPI);
|
|
});
|
|
|
|
describe('Hydrate', () => {
|
|
it('Calls the correct stores', async () => {
|
|
const collectionsStore = useCollectionsStore({});
|
|
collectionsStore.getCollections = jest.fn();
|
|
await hydrate();
|
|
expect(collectionsStore.getCollections).toHaveBeenCalled();
|
|
});
|
|
|
|
it('Sets hydrated let after it is done', async () => {
|
|
await hydrate();
|
|
expect(hydrated).toBe(true);
|
|
});
|
|
|
|
it('Does not hydrate when already hydrated', async () => {
|
|
await hydrate();
|
|
|
|
const collectionsStore = useCollectionsStore({});
|
|
collectionsStore.getCollections = jest.fn();
|
|
|
|
await hydrate();
|
|
|
|
expect(collectionsStore.getCollections).not.toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe('Dehydrate', () => {
|
|
it('Calls resets functions of correct stores', async () => {
|
|
const collectionsStore = useCollectionsStore({});
|
|
collectionsStore.reset = jest.fn();
|
|
await dehydrate();
|
|
expect(collectionsStore.reset).toHaveBeenCalled();
|
|
});
|
|
|
|
it('Sets hydrated let after it is done', async () => {
|
|
await dehydrate();
|
|
expect(hydrated).toBe(false);
|
|
});
|
|
|
|
it('Does not hydrate when already hydrated', async () => {
|
|
await dehydrate();
|
|
|
|
const collectionsStore = useCollectionsStore({});
|
|
collectionsStore.reset = jest.fn();
|
|
|
|
await dehydrate();
|
|
|
|
expect(collectionsStore.reset).not.toHaveBeenCalled();
|
|
});
|
|
});
|
|
});
|