vendor: amis 6.13.0 base (fork root)
This commit is contained in:
53
packages/amis/__tests__/stores/index.test.ts
Normal file
53
packages/amis/__tests__/stores/index.test.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import {RendererStore} from '../../src';
|
||||
import {getSnapshot, getEnv} from 'mobx-state-tree';
|
||||
import {ServiceStore} from '../../src';
|
||||
|
||||
test('store:index', () => {
|
||||
const store = RendererStore.create({});
|
||||
|
||||
expect(getSnapshot(store)).toMatchSnapshot();
|
||||
|
||||
const serviceStore = ServiceStore.create({
|
||||
path: '/xxx',
|
||||
storeType: ServiceStore.name,
|
||||
id: '1'
|
||||
});
|
||||
store.addStore(serviceStore);
|
||||
|
||||
expect(getSnapshot(store)).toMatchSnapshot();
|
||||
|
||||
const serviceStore2 = ServiceStore.create({
|
||||
path: '/yyy',
|
||||
storeType: ServiceStore.name,
|
||||
id: '2',
|
||||
parentId: '1'
|
||||
});
|
||||
|
||||
store.addStore(serviceStore2);
|
||||
|
||||
expect(getSnapshot(store)).toMatchSnapshot();
|
||||
|
||||
expect(serviceStore2.parentStore).toEqual(serviceStore);
|
||||
|
||||
store.removeStore(serviceStore2);
|
||||
expect(getSnapshot(store)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('store:index env', () => {
|
||||
const fetcher = jest.fn();
|
||||
const notify = jest.fn();
|
||||
const isCancel = jest.fn(() => false);
|
||||
|
||||
const store = RendererStore.create(
|
||||
{},
|
||||
{
|
||||
fetcher,
|
||||
notify,
|
||||
isCancel
|
||||
}
|
||||
);
|
||||
|
||||
expect(store.fetcher).toBe(fetcher);
|
||||
expect(store.notify).toBe(notify);
|
||||
expect(store.isCancel).toBe(isCancel);
|
||||
});
|
||||
Reference in New Issue
Block a user