piral-modals 0.15.0-alpha.4332 → 0.15.0-alpha.4345
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 +11 -11
- package/src/create.test.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-modals",
|
|
3
|
-
"version": "0.15.0-alpha.
|
|
3
|
+
"version": "0.15.0-alpha.4345",
|
|
4
4
|
"description": "Plugin for the display of modal dialogs 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.4345",
|
|
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": "56ecd6ad080b3d275752b19afcf8435e4bd09140"
|
|
69
73
|
}
|
package/src/actions.test.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import create from 'zustand';
|
|
2
2
|
import { createListener } from 'piral-base';
|
|
3
3
|
import { createActions } from 'piral-core';
|
|
4
4
|
import { registerModal, unregisterModal, openModal, closeModal } from './actions';
|
|
5
5
|
|
|
6
6
|
describe('Modals Actions Module', () => {
|
|
7
7
|
it('registerModal and unregisterModal', () => {
|
|
8
|
-
const state =
|
|
8
|
+
const state: any = create(() => ({
|
|
9
9
|
foo: 5,
|
|
10
10
|
registry: {
|
|
11
11
|
foo: 5,
|
|
12
12
|
modals: {},
|
|
13
13
|
},
|
|
14
|
-
});
|
|
14
|
+
}));
|
|
15
15
|
const ctx = createActions(state, createListener({}));
|
|
16
16
|
registerModal(ctx, 'foo', 10);
|
|
17
|
-
expect(
|
|
17
|
+
expect(state.getState()).toEqual({
|
|
18
18
|
foo: 5,
|
|
19
19
|
registry: {
|
|
20
20
|
foo: 5,
|
|
@@ -24,7 +24,7 @@ describe('Modals Actions Module', () => {
|
|
|
24
24
|
},
|
|
25
25
|
});
|
|
26
26
|
unregisterModal(ctx, 'foo');
|
|
27
|
-
expect(
|
|
27
|
+
expect(state.getState()).toEqual({
|
|
28
28
|
foo: 5,
|
|
29
29
|
registry: {
|
|
30
30
|
foo: 5,
|
|
@@ -34,26 +34,26 @@ describe('Modals Actions Module', () => {
|
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
it('openModal adds a new modal', () => {
|
|
37
|
-
const state =
|
|
37
|
+
const state: any = create(() => ({
|
|
38
38
|
foo: 5,
|
|
39
39
|
modals: [{ id: 'b' }],
|
|
40
|
-
});
|
|
40
|
+
}));
|
|
41
41
|
const ctx = createActions(state, createListener({}));
|
|
42
42
|
openModal(ctx, { id: 'a' });
|
|
43
|
-
expect(
|
|
43
|
+
expect(state.getState()).toEqual({
|
|
44
44
|
foo: 5,
|
|
45
45
|
modals: [{ id: 'a' }, { id: 'b' }],
|
|
46
46
|
});
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
it('closeModal removes an existing modal', () => {
|
|
50
|
-
const state =
|
|
50
|
+
const state: any = create(() => ({
|
|
51
51
|
foo: 5,
|
|
52
52
|
modals: [{ id: 'a' }, { id: 'b' }, { id: 'c' }],
|
|
53
|
-
});
|
|
53
|
+
}));
|
|
54
54
|
const ctx = createActions(state, createListener({}));
|
|
55
55
|
closeModal(ctx, { id: 'b' });
|
|
56
|
-
expect(
|
|
56
|
+
expect(state.getState()).toEqual({
|
|
57
57
|
foo: 5,
|
|
58
58
|
modals: [{ id: 'a' }, { id: 'c' }],
|
|
59
59
|
});
|
package/src/create.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import create from 'zustand';
|
|
2
2
|
import { createElement, FC } from 'react';
|
|
3
3
|
import { createModalsApi } from './create';
|
|
4
4
|
|
|
@@ -6,11 +6,11 @@ const StubComponent: FC = (props) => createElement('div', props);
|
|
|
6
6
|
StubComponent.displayName = 'StubComponent';
|
|
7
7
|
|
|
8
8
|
function createMockContainer() {
|
|
9
|
-
const state =
|
|
9
|
+
const state = create(() => ({
|
|
10
10
|
registry: {
|
|
11
11
|
extensions: {},
|
|
12
12
|
},
|
|
13
|
-
});
|
|
13
|
+
}));
|
|
14
14
|
return {
|
|
15
15
|
context: {
|
|
16
16
|
on: jest.fn(),
|
|
@@ -23,7 +23,7 @@ function createMockContainer() {
|
|
|
23
23
|
},
|
|
24
24
|
state,
|
|
25
25
|
dispatch(update) {
|
|
26
|
-
|
|
26
|
+
state.setState(update(state.getState()));
|
|
27
27
|
},
|
|
28
28
|
} as any,
|
|
29
29
|
api: {} as any,
|