piral-containers 0.15.0-alpha.4332 → 0.15.0-alpha.4396
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -3
- package/src/actions.test.ts +8 -8
- package/src/create.test.tsx +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-containers",
|
|
3
|
-
"version": "0.15.0-alpha.
|
|
3
|
+
"version": "0.15.0-alpha.4396",
|
|
4
4
|
"description": "Plugin for creating a pilet state container in Piral.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral",
|
|
@@ -31,6 +31,10 @@
|
|
|
31
31
|
"./lib/*": {
|
|
32
32
|
"require": "./lib/*"
|
|
33
33
|
},
|
|
34
|
+
"./_/*": {
|
|
35
|
+
"import": "./esm/*.js",
|
|
36
|
+
"require": "./lib/*.js"
|
|
37
|
+
},
|
|
34
38
|
"./package.json": "./package.json"
|
|
35
39
|
},
|
|
36
40
|
"sideEffects": false,
|
|
@@ -58,12 +62,12 @@
|
|
|
58
62
|
},
|
|
59
63
|
"devDependencies": {
|
|
60
64
|
"@types/react": "^18.0.0",
|
|
61
|
-
"piral-core": "0.15.0-alpha.
|
|
65
|
+
"piral-core": "0.15.0-alpha.4396",
|
|
62
66
|
"react": "^18.0.0"
|
|
63
67
|
},
|
|
64
68
|
"peerDependencies": {
|
|
65
69
|
"piral-core": "0.14.x || 0.15.x",
|
|
66
70
|
"react": ">=16.8.0"
|
|
67
71
|
},
|
|
68
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "62abff4d61634b3ecffda2407f1c29f1de929b4c"
|
|
69
73
|
}
|
package/src/actions.test.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import create from 'zustand';
|
|
2
2
|
import { createState, destroyState, replaceState } from './actions';
|
|
3
3
|
|
|
4
4
|
function createMockContainer() {
|
|
5
|
-
const state =
|
|
5
|
+
const state = create(() => ({}));
|
|
6
6
|
return {
|
|
7
7
|
context: {
|
|
8
8
|
converters: {},
|
|
@@ -15,7 +15,7 @@ function createMockContainer() {
|
|
|
15
15
|
return read(state);
|
|
16
16
|
},
|
|
17
17
|
dispatch(update) {
|
|
18
|
-
|
|
18
|
+
state.setState(update(state.getState()));
|
|
19
19
|
},
|
|
20
20
|
} as any,
|
|
21
21
|
api: {} as any,
|
|
@@ -29,7 +29,7 @@ describe('Piral-Containers actions module', () => {
|
|
|
29
29
|
bar: 'qxz',
|
|
30
30
|
};
|
|
31
31
|
createState(context, 'foo', initialData);
|
|
32
|
-
const state: any =
|
|
32
|
+
const state: any = (context.state.getState());
|
|
33
33
|
expect(state.containers.foo).toBe(initialData);
|
|
34
34
|
});
|
|
35
35
|
|
|
@@ -40,7 +40,7 @@ describe('Piral-Containers actions module', () => {
|
|
|
40
40
|
};
|
|
41
41
|
createState(context, 'foo', initialData);
|
|
42
42
|
destroyState(context, 'foo');
|
|
43
|
-
const state: any =
|
|
43
|
+
const state: any = (context.state.getState());
|
|
44
44
|
expect(state.containers.foo).toBeUndefined();
|
|
45
45
|
});
|
|
46
46
|
|
|
@@ -54,7 +54,7 @@ describe('Piral-Containers actions module', () => {
|
|
|
54
54
|
};
|
|
55
55
|
createState(context, 'foo', initialData);
|
|
56
56
|
replaceState(context, 'foo', (state) => updatedData);
|
|
57
|
-
const state: any =
|
|
57
|
+
const state: any = (context.state.getState());
|
|
58
58
|
expect(state.containers.foo).toEqual({
|
|
59
59
|
...initialData,
|
|
60
60
|
...updatedData,
|
|
@@ -71,7 +71,7 @@ describe('Piral-Containers actions module', () => {
|
|
|
71
71
|
};
|
|
72
72
|
createState(context, 'foo', initialData);
|
|
73
73
|
replaceState(context, 'foo', (state) => updatedData);
|
|
74
|
-
const state: any =
|
|
74
|
+
const state: any = (context.state.getState());
|
|
75
75
|
expect(state.containers.foo).toEqual({
|
|
76
76
|
...initialData,
|
|
77
77
|
...updatedData,
|
|
@@ -85,7 +85,7 @@ describe('Piral-Containers actions module', () => {
|
|
|
85
85
|
};
|
|
86
86
|
createState(context, 'foo', initialData);
|
|
87
87
|
replaceState(context, 'foo', (state) => state);
|
|
88
|
-
const state: any =
|
|
88
|
+
const state: any = (context.state.getState());
|
|
89
89
|
expect(state.containers.foo).toEqual(initialData);
|
|
90
90
|
});
|
|
91
91
|
});
|
package/src/create.test.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import create from 'zustand';
|
|
2
3
|
import { mount } from 'enzyme';
|
|
3
4
|
import { StateContext } from 'piral-core';
|
|
4
|
-
import { Atom, swap, deref } from '@dbeining/react-atom';
|
|
5
5
|
import { createContainersApi } from './create';
|
|
6
6
|
|
|
7
7
|
function createMockContainer() {
|
|
8
|
-
const state =
|
|
8
|
+
const state = create(() => ({}));
|
|
9
9
|
return {
|
|
10
10
|
context: {
|
|
11
11
|
on: jest.fn(),
|
|
@@ -18,10 +18,10 @@ function createMockContainer() {
|
|
|
18
18
|
},
|
|
19
19
|
state,
|
|
20
20
|
readState(read) {
|
|
21
|
-
return read(
|
|
21
|
+
return read(state.getState());
|
|
22
22
|
},
|
|
23
23
|
dispatch(update) {
|
|
24
|
-
|
|
24
|
+
state.setState(update(state.getState()));
|
|
25
25
|
},
|
|
26
26
|
} as any,
|
|
27
27
|
api: {} as any,
|