testeranto 0.47.25 → 0.47.26
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/dist/common/subPackages/{react/jsx/mounted.web.js → react-dom/component/node.js} +2 -2
- package/dist/common/subPackages/react-dom/jsx/web.js +76 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/subPackages/{react/jsx/mounted.web.js → react-dom/component/node.js} +1 -1
- package/dist/module/subPackages/react-dom/jsx/web.js +48 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/types/Node.d.ts +9 -9
- package/dist/types/Web.d.ts +9 -9
- package/dist/types/subPackages/react/component/node.d.ts +10 -7
- package/dist/types/subPackages/react/jsx/node.d.ts +6 -4
- package/dist/types/subPackages/react/jsx/web.d.ts +6 -4
- package/dist/types/subPackages/react-dom/component/node.d.ts +19 -0
- package/dist/types/subPackages/react-dom/component/web.d.ts +19 -0
- package/dist/types/subPackages/react-dom/jsx/web.d.ts +16 -0
- package/dist/types/subPackages/react-test-render/component/node.d.ts +6 -6
- package/dist/types/subPackages/react-test-render/component/web.d.ts +6 -6
- package/dist/types/subPackages/react-test-render/jsx/node.d.ts +6 -6
- package/dist/types/subPackages/react-test-render/jsx/web.d.ts +7 -7
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/Node.ts +21 -15
- package/src/Web.ts +19 -13
- package/src/subPackages/react/component/node.ts +38 -15
- package/src/subPackages/react/jsx/node.ts +19 -13
- package/src/subPackages/react/jsx/web.ts +19 -13
- package/src/subPackages/{react/jsx/mounted.web.ts → react-dom/component/node.ts} +24 -18
- package/src/subPackages/{react/component/mounted.web.ts → react-dom/component/web.ts} +23 -17
- package/src/subPackages/react-dom/jsx/web.ts +117 -0
- package/src/subPackages/react-test-render/component/node.ts +16 -10
- package/src/subPackages/react-test-render/component/web.ts +16 -10
- package/src/subPackages/react-test-render/jsx/node.ts +13 -7
- package/src/subPackages/react-test-render/jsx/web.ts +16 -11
- package/dist/types/subPackages/react/component/mounted.web.d.ts +0 -12
- package/dist/types/subPackages/react/jsx/mounted.web.d.ts +0 -12
- /package/dist/common/subPackages/{react/component/mounted.web.js → react-dom/component/web.js} +0 -0
- /package/dist/module/subPackages/{react/component/mounted.web.js → react-dom/component/web.js} +0 -0
package/src/Node.ts
CHANGED
|
@@ -43,43 +43,49 @@ const receiveTestResourceConfig = async (t, testresource) => {
|
|
|
43
43
|
export default async <
|
|
44
44
|
TestShape extends ITTestShape,
|
|
45
45
|
IInput,
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
ISubject,
|
|
47
|
+
IStore,
|
|
48
48
|
ISelection,
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
IWhenShape,
|
|
50
|
+
IThenShape,
|
|
51
51
|
IState
|
|
52
52
|
>(
|
|
53
53
|
input: IInput,
|
|
54
|
-
testSpecification: ITestSpecification<
|
|
54
|
+
testSpecification: ITestSpecification<
|
|
55
|
+
TestShape,
|
|
56
|
+
ISubject,
|
|
57
|
+
IStore,
|
|
58
|
+
ISelection,
|
|
59
|
+
IThenShape
|
|
60
|
+
>,
|
|
55
61
|
testImplementation,
|
|
56
62
|
testInterface: {
|
|
57
63
|
actionHandler?: (b: (...any) => any) => any;
|
|
58
64
|
andWhen: (
|
|
59
|
-
store:
|
|
65
|
+
store: IStore,
|
|
60
66
|
actioner,
|
|
61
67
|
testResource: ITTestResourceConfiguration
|
|
62
68
|
) => Promise<ISelection>;
|
|
63
69
|
butThen?: (
|
|
64
|
-
store:
|
|
70
|
+
store: IStore,
|
|
65
71
|
callback,
|
|
66
72
|
testResource: ITTestResourceConfiguration
|
|
67
73
|
) => Promise<ISelection>;
|
|
68
|
-
assertioner?: (t:
|
|
74
|
+
assertioner?: (t: IThenShape) => any;
|
|
69
75
|
|
|
70
|
-
afterAll?: (store:
|
|
76
|
+
afterAll?: (store: IStore, artificer: ITestArtificer) => any;
|
|
71
77
|
afterEach?: (
|
|
72
|
-
store:
|
|
78
|
+
store: IStore,
|
|
73
79
|
key: string,
|
|
74
80
|
artificer: ITestArtificer
|
|
75
81
|
) => Promise<unknown>;
|
|
76
|
-
beforeAll?: (input: IInput, artificer: ITestArtificer) => Promise<
|
|
82
|
+
beforeAll?: (input: IInput, artificer: ITestArtificer) => Promise<ISubject>;
|
|
77
83
|
beforeEach?: (
|
|
78
|
-
subject:
|
|
84
|
+
subject: ISubject,
|
|
79
85
|
initialValues,
|
|
80
86
|
testResource: ITTestResourceConfiguration,
|
|
81
87
|
artificer: ITestArtificer
|
|
82
|
-
) => Promise<
|
|
88
|
+
) => Promise<IStore>;
|
|
83
89
|
},
|
|
84
90
|
testResourceRequirement: ITTestResourceRequest = defaultTestResourceRequirement,
|
|
85
91
|
) => {
|
|
@@ -91,11 +97,11 @@ export default async <
|
|
|
91
97
|
testInterface,
|
|
92
98
|
testResourceRequirement,
|
|
93
99
|
testInterface.assertioner || (async (t) => t as any),
|
|
94
|
-
testInterface.beforeEach || async function (subject:
|
|
100
|
+
testInterface.beforeEach || async function (subject: ISubject, initialValues: any, testResource: any) {
|
|
95
101
|
return subject as any;
|
|
96
102
|
},
|
|
97
103
|
testInterface.afterEach || (async (s) => s),
|
|
98
|
-
testInterface.afterAll || ((store:
|
|
104
|
+
testInterface.afterAll || ((store: IStore) => undefined),
|
|
99
105
|
testInterface.butThen || (async (a) => a as any),
|
|
100
106
|
testInterface.andWhen,
|
|
101
107
|
testInterface.actionHandler ||
|
package/src/Web.ts
CHANGED
|
@@ -40,43 +40,49 @@ const receiveTestResourceConfig = async (t, testresource) => {
|
|
|
40
40
|
export default async <
|
|
41
41
|
TestShape extends ITTestShape,
|
|
42
42
|
IInput,
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
ISubject,
|
|
44
|
+
IStore,
|
|
45
45
|
ISelection,
|
|
46
46
|
WhenShape,
|
|
47
|
-
|
|
47
|
+
IThenShape,
|
|
48
48
|
IState
|
|
49
49
|
>(
|
|
50
50
|
input: IInput,
|
|
51
|
-
testSpecification: ITestSpecification<
|
|
51
|
+
testSpecification: ITestSpecification<
|
|
52
|
+
TestShape,
|
|
53
|
+
ISubject,
|
|
54
|
+
IStore,
|
|
55
|
+
ISelection,
|
|
56
|
+
IThenShape
|
|
57
|
+
>,
|
|
52
58
|
testImplementation,
|
|
53
59
|
testInterface: {
|
|
54
60
|
actionHandler?: (b: (...any) => any) => any;
|
|
55
61
|
andWhen: (
|
|
56
|
-
store:
|
|
62
|
+
store: IStore,
|
|
57
63
|
actioner,
|
|
58
64
|
testResource: ITTestResourceConfiguration
|
|
59
65
|
) => Promise<ISelection>;
|
|
60
66
|
butThen?: (
|
|
61
|
-
store:
|
|
67
|
+
store: IStore,
|
|
62
68
|
callback,
|
|
63
69
|
testResource: ITTestResourceConfiguration
|
|
64
70
|
) => Promise<ISelection>;
|
|
65
|
-
assertioner?: (t:
|
|
71
|
+
assertioner?: (t: IThenShape) => any;
|
|
66
72
|
|
|
67
|
-
afterAll?: (store:
|
|
73
|
+
afterAll?: (store: IStore, artificer: ITestArtificer) => any;
|
|
68
74
|
afterEach?: (
|
|
69
|
-
store:
|
|
75
|
+
store: IStore,
|
|
70
76
|
key: string,
|
|
71
77
|
artificer: ITestArtificer
|
|
72
78
|
) => Promise<unknown>;
|
|
73
|
-
beforeAll?: (input: IInput, artificer: ITestArtificer) => Promise<
|
|
79
|
+
beforeAll?: (input: IInput, artificer: ITestArtificer) => Promise<ISubject>;
|
|
74
80
|
beforeEach?: (
|
|
75
|
-
subject:
|
|
81
|
+
subject: ISubject,
|
|
76
82
|
initialValues,
|
|
77
83
|
testResource: ITTestResourceConfiguration,
|
|
78
84
|
artificer: ITestArtificer
|
|
79
|
-
) => Promise<
|
|
85
|
+
) => Promise<IStore>;
|
|
80
86
|
},
|
|
81
87
|
testResourceRequirement: ITTestResourceRequest = defaultTestResourceRequirement
|
|
82
88
|
) => {
|
|
@@ -93,7 +99,7 @@ export default async <
|
|
|
93
99
|
return subject as any;
|
|
94
100
|
},
|
|
95
101
|
testInterface.afterEach || (async (s) => s),
|
|
96
|
-
testInterface.afterAll || ((store:
|
|
102
|
+
testInterface.afterAll || ((store: IStore) => undefined),
|
|
97
103
|
testInterface.butThen || (async (a) => a as any),
|
|
98
104
|
testInterface.andWhen,
|
|
99
105
|
testInterface.actionHandler ||
|
|
@@ -1,26 +1,49 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
|
|
3
3
|
import { ITTestShape, ITestImplementation, ITestSpecification } from "../../../core";
|
|
4
4
|
import Testeranto from "../../../Node";
|
|
5
5
|
|
|
6
|
-
type
|
|
7
|
-
type
|
|
6
|
+
type IWhenShape = any;
|
|
7
|
+
type IThenShape = any;
|
|
8
8
|
|
|
9
|
-
type InitialState = unknown;
|
|
10
9
|
type IInput = typeof React.Component;
|
|
11
|
-
type ISelection = CElement<any, any>
|
|
12
|
-
type Store = CElement<any, any>
|
|
13
|
-
type Subject = CElement<any, any>
|
|
10
|
+
type ISelection = React.CElement<any, any>
|
|
11
|
+
type Store = React.CElement<any, any>
|
|
12
|
+
type Subject = React.CElement<any, any>
|
|
14
13
|
|
|
15
|
-
export
|
|
14
|
+
export type IImpl<
|
|
15
|
+
ISpec extends ITTestShape,
|
|
16
|
+
IState
|
|
17
|
+
> = ITestImplementation<
|
|
18
|
+
IState,
|
|
19
|
+
ISelection,
|
|
20
|
+
IWhenShape,
|
|
21
|
+
IThenShape,
|
|
22
|
+
ISpec
|
|
23
|
+
>
|
|
24
|
+
|
|
25
|
+
export type ISpec<
|
|
26
|
+
T extends ITTestShape
|
|
27
|
+
> = ITestSpecification<
|
|
28
|
+
T,
|
|
29
|
+
Subject,
|
|
30
|
+
Store,
|
|
31
|
+
ISelection,
|
|
32
|
+
IThenShape
|
|
33
|
+
>;
|
|
34
|
+
|
|
35
|
+
export default <
|
|
36
|
+
ITestShape extends ITTestShape,
|
|
37
|
+
IState
|
|
38
|
+
>(
|
|
16
39
|
testImplementations: ITestImplementation<
|
|
17
|
-
|
|
40
|
+
IState,
|
|
18
41
|
ISelection,
|
|
19
|
-
|
|
20
|
-
|
|
42
|
+
IWhenShape,
|
|
43
|
+
IThenShape,
|
|
21
44
|
ITestShape
|
|
22
45
|
>,
|
|
23
|
-
testSpecifications:
|
|
46
|
+
testSpecifications: ISpec<ITestShape>,
|
|
24
47
|
testInput: IInput
|
|
25
48
|
) => {
|
|
26
49
|
return Testeranto<
|
|
@@ -29,9 +52,9 @@ export default <ITestShape extends ITTestShape>(
|
|
|
29
52
|
Subject,
|
|
30
53
|
Store,
|
|
31
54
|
ISelection,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
55
|
+
IThenShape,
|
|
56
|
+
IWhenShape,
|
|
57
|
+
IState
|
|
35
58
|
>(
|
|
36
59
|
testInput,
|
|
37
60
|
testSpecifications,
|
|
@@ -3,34 +3,40 @@ import React, { CElement } from "react";
|
|
|
3
3
|
import { ITTestShape, ITestImplementation, ITestSpecification } from "../../../core";
|
|
4
4
|
import Testeranto from "../../../Node";
|
|
5
5
|
|
|
6
|
-
type
|
|
7
|
-
type
|
|
6
|
+
type IWhenShape = any;
|
|
7
|
+
type IThenShape = any;
|
|
8
8
|
|
|
9
9
|
type InitialState = unknown;
|
|
10
10
|
type IInput = typeof React.Component;
|
|
11
11
|
type ISelection = CElement<any, any>
|
|
12
|
-
type
|
|
13
|
-
type
|
|
12
|
+
type IStore = CElement<any, any>
|
|
13
|
+
type ISubject = CElement<any, any>
|
|
14
14
|
|
|
15
15
|
export default <ITestShape extends ITTestShape>(
|
|
16
16
|
testImplementations: ITestImplementation<
|
|
17
17
|
InitialState,
|
|
18
18
|
ISelection,
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
IWhenShape,
|
|
20
|
+
IThenShape,
|
|
21
21
|
ITestShape
|
|
22
22
|
>,
|
|
23
|
-
testSpecifications: ITestSpecification<
|
|
23
|
+
testSpecifications: ITestSpecification<
|
|
24
|
+
ITestShape,
|
|
25
|
+
ISubject,
|
|
26
|
+
IStore,
|
|
27
|
+
ISelection,
|
|
28
|
+
IThenShape
|
|
29
|
+
>,
|
|
24
30
|
testInput: IInput
|
|
25
31
|
) => {
|
|
26
32
|
return Testeranto<
|
|
27
33
|
ITestShape,
|
|
28
34
|
IInput,
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
ISubject,
|
|
36
|
+
IStore,
|
|
31
37
|
ISelection,
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
IThenShape,
|
|
39
|
+
IWhenShape,
|
|
34
40
|
InitialState
|
|
35
41
|
>(
|
|
36
42
|
testInput,
|
|
@@ -38,13 +44,13 @@ export default <ITestShape extends ITTestShape>(
|
|
|
38
44
|
testImplementations,
|
|
39
45
|
{
|
|
40
46
|
beforeEach: async (
|
|
41
|
-
): Promise<
|
|
47
|
+
): Promise<IStore> => {
|
|
42
48
|
return new Promise((resolve, rej) => {
|
|
43
49
|
resolve(React.createElement(testInput, {
|
|
44
50
|
}, []));
|
|
45
51
|
});
|
|
46
52
|
},
|
|
47
|
-
andWhen: function (s:
|
|
53
|
+
andWhen: function (s: IStore, actioner): Promise<ISelection> {
|
|
48
54
|
return actioner()(s);
|
|
49
55
|
},
|
|
50
56
|
},
|
|
@@ -5,34 +5,40 @@ import Testeranto from "../../../Web";
|
|
|
5
5
|
|
|
6
6
|
import { CElement } from "react";
|
|
7
7
|
|
|
8
|
-
type
|
|
9
|
-
type
|
|
8
|
+
type IWhenShape = any;
|
|
9
|
+
type IThenShape = any;
|
|
10
10
|
|
|
11
11
|
type InitialState = unknown;
|
|
12
12
|
type IInput = typeof React.Component;
|
|
13
13
|
type ISelection = CElement<any, any>
|
|
14
|
-
type
|
|
15
|
-
type
|
|
14
|
+
type IStore = CElement<any, any>
|
|
15
|
+
type ISubject = CElement<any, any>
|
|
16
16
|
|
|
17
17
|
export default <ITestShape extends ITTestShape>(
|
|
18
18
|
testImplementations: ITestImplementation<
|
|
19
19
|
InitialState,
|
|
20
20
|
ISelection,
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
IWhenShape,
|
|
22
|
+
IThenShape,
|
|
23
23
|
ITestShape
|
|
24
24
|
>,
|
|
25
|
-
testSpecifications: ITestSpecification<
|
|
25
|
+
testSpecifications: ITestSpecification<
|
|
26
|
+
ITestShape,
|
|
27
|
+
ISubject,
|
|
28
|
+
IStore,
|
|
29
|
+
ISelection,
|
|
30
|
+
IThenShape
|
|
31
|
+
>,
|
|
26
32
|
testInput: IInput
|
|
27
33
|
) => {
|
|
28
34
|
return Testeranto<
|
|
29
35
|
ITestShape,
|
|
30
36
|
IInput,
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
ISubject,
|
|
38
|
+
IStore,
|
|
33
39
|
ISelection,
|
|
34
|
-
|
|
35
|
-
|
|
40
|
+
IThenShape,
|
|
41
|
+
IWhenShape,
|
|
36
42
|
InitialState
|
|
37
43
|
>(
|
|
38
44
|
testInput,
|
|
@@ -40,13 +46,13 @@ export default <ITestShape extends ITTestShape>(
|
|
|
40
46
|
testImplementations,
|
|
41
47
|
{
|
|
42
48
|
beforeEach: async (
|
|
43
|
-
): Promise<
|
|
49
|
+
): Promise<IStore> => {
|
|
44
50
|
return new Promise((resolve, rej) => {
|
|
45
51
|
resolve(React.createElement(testInput, {
|
|
46
52
|
}, []));
|
|
47
53
|
});
|
|
48
54
|
},
|
|
49
|
-
andWhen: function (s:
|
|
55
|
+
andWhen: function (s: IStore, actioner): Promise<ISelection> {
|
|
50
56
|
return actioner()(s);
|
|
51
57
|
},
|
|
52
58
|
},
|
|
@@ -2,23 +2,23 @@ import React, { CElement } from "react";
|
|
|
2
2
|
import ReactDom from "react-dom/client";
|
|
3
3
|
|
|
4
4
|
import { ITTestShape, ITestImplementation, ITestSpecification } from "../../../core";
|
|
5
|
-
import Testeranto from "../../../
|
|
5
|
+
import Testeranto from "../../../Node";
|
|
6
6
|
|
|
7
7
|
type IInput = typeof React.Component;
|
|
8
8
|
type InitialState = unknown;
|
|
9
|
-
type
|
|
10
|
-
type
|
|
9
|
+
type IWhenShape = any;
|
|
10
|
+
type IThenShape = any;
|
|
11
11
|
type ISelection = {
|
|
12
12
|
htmlElement: HTMLElement,
|
|
13
13
|
reactElement: CElement<any, any>,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
type
|
|
16
|
+
type IStore = {
|
|
17
17
|
htmlElement: HTMLElement,
|
|
18
18
|
reactElement: CElement<any, any>,
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
type
|
|
21
|
+
type ISubject = {
|
|
22
22
|
htmlElement: HTMLElement
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -26,11 +26,17 @@ export default <ITestShape extends ITTestShape>(
|
|
|
26
26
|
testImplementations: ITestImplementation<
|
|
27
27
|
InitialState,
|
|
28
28
|
ISelection,
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
IWhenShape,
|
|
30
|
+
IThenShape,
|
|
31
31
|
ITestShape
|
|
32
32
|
>,
|
|
33
|
-
testSpecifications: ITestSpecification<
|
|
33
|
+
testSpecifications: ITestSpecification<
|
|
34
|
+
ITestShape,
|
|
35
|
+
ISubject,
|
|
36
|
+
IStore,
|
|
37
|
+
ISelection,
|
|
38
|
+
IThenShape
|
|
39
|
+
>,
|
|
34
40
|
testInput: IInput
|
|
35
41
|
) => {
|
|
36
42
|
class TesterantoComponent extends testInput {
|
|
@@ -48,11 +54,11 @@ export default <ITestShape extends ITTestShape>(
|
|
|
48
54
|
return Testeranto<
|
|
49
55
|
ITestShape,
|
|
50
56
|
IInput,
|
|
51
|
-
|
|
52
|
-
|
|
57
|
+
ISubject,
|
|
58
|
+
IStore,
|
|
53
59
|
ISelection,
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
IThenShape,
|
|
61
|
+
IWhenShape,
|
|
56
62
|
InitialState
|
|
57
63
|
>(
|
|
58
64
|
testInput,
|
|
@@ -62,7 +68,7 @@ export default <ITestShape extends ITTestShape>(
|
|
|
62
68
|
beforeAll: async (
|
|
63
69
|
prototype,
|
|
64
70
|
artificer
|
|
65
|
-
): Promise<
|
|
71
|
+
): Promise<ISubject> => {
|
|
66
72
|
return await new Promise((resolve, rej) => {
|
|
67
73
|
document.addEventListener("DOMContentLoaded", function () {
|
|
68
74
|
const elem = document.getElementById("root");
|
|
@@ -77,7 +83,7 @@ export default <ITestShape extends ITTestShape>(
|
|
|
77
83
|
ndx,
|
|
78
84
|
testRsource,
|
|
79
85
|
artificer
|
|
80
|
-
): Promise<
|
|
86
|
+
): Promise<IStore> => {
|
|
81
87
|
return new Promise((resolve, rej) => {
|
|
82
88
|
const reactElement = React.createElement(TesterantoComponent, {
|
|
83
89
|
done: (reactElement) => {
|
|
@@ -92,20 +98,20 @@ export default <ITestShape extends ITTestShape>(
|
|
|
92
98
|
ReactDom.createRoot(htmlElement).render(reactElement);
|
|
93
99
|
});
|
|
94
100
|
},
|
|
95
|
-
andWhen: function (s:
|
|
101
|
+
andWhen: function (s: IStore, actioner): Promise<ISelection> {
|
|
96
102
|
return actioner()(s);
|
|
97
103
|
},
|
|
98
|
-
butThen: async function (s:
|
|
104
|
+
butThen: async function (s: IStore): Promise<ISelection> {
|
|
99
105
|
return s;
|
|
100
106
|
},
|
|
101
107
|
afterEach: async function (
|
|
102
|
-
store:
|
|
108
|
+
store: IStore,
|
|
103
109
|
ndx,
|
|
104
110
|
artificer
|
|
105
111
|
) {
|
|
106
112
|
return {};
|
|
107
113
|
},
|
|
108
|
-
afterAll: (store:
|
|
114
|
+
afterAll: (store: IStore, artificer) => {
|
|
109
115
|
return;
|
|
110
116
|
},
|
|
111
117
|
},
|
|
@@ -6,19 +6,19 @@ import Testeranto from "../../../Web";
|
|
|
6
6
|
|
|
7
7
|
type IInput = typeof React.Component;
|
|
8
8
|
type InitialState = unknown;
|
|
9
|
-
type
|
|
10
|
-
type
|
|
9
|
+
type IWhenShape = any;
|
|
10
|
+
type IThenShape = any;
|
|
11
11
|
type ISelection = {
|
|
12
12
|
htmlElement: HTMLElement,
|
|
13
13
|
reactElement: CElement<any, any>,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
type
|
|
16
|
+
type IStore = {
|
|
17
17
|
htmlElement: HTMLElement,
|
|
18
18
|
reactElement: CElement<any, any>,
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
type
|
|
21
|
+
type ISubject = {
|
|
22
22
|
htmlElement: HTMLElement
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -26,11 +26,17 @@ export default <ITestShape extends ITTestShape>(
|
|
|
26
26
|
testImplementations: ITestImplementation<
|
|
27
27
|
InitialState,
|
|
28
28
|
ISelection,
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
IWhenShape,
|
|
30
|
+
IThenShape,
|
|
31
31
|
ITestShape
|
|
32
32
|
>,
|
|
33
|
-
testSpecifications: ITestSpecification<
|
|
33
|
+
testSpecifications: ITestSpecification<
|
|
34
|
+
ITestShape,
|
|
35
|
+
ISubject,
|
|
36
|
+
IStore,
|
|
37
|
+
ISelection,
|
|
38
|
+
IThenShape
|
|
39
|
+
>,
|
|
34
40
|
testInput: IInput
|
|
35
41
|
) => {
|
|
36
42
|
class TesterantoComponent extends testInput {
|
|
@@ -48,11 +54,11 @@ export default <ITestShape extends ITTestShape>(
|
|
|
48
54
|
return Testeranto<
|
|
49
55
|
ITestShape,
|
|
50
56
|
IInput,
|
|
51
|
-
|
|
52
|
-
|
|
57
|
+
ISubject,
|
|
58
|
+
IStore,
|
|
53
59
|
ISelection,
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
IThenShape,
|
|
61
|
+
IWhenShape,
|
|
56
62
|
InitialState
|
|
57
63
|
>(
|
|
58
64
|
testInput,
|
|
@@ -62,7 +68,7 @@ export default <ITestShape extends ITTestShape>(
|
|
|
62
68
|
beforeAll: async (
|
|
63
69
|
prototype,
|
|
64
70
|
artificer
|
|
65
|
-
): Promise<
|
|
71
|
+
): Promise<ISubject> => {
|
|
66
72
|
return await new Promise((resolve, rej) => {
|
|
67
73
|
document.addEventListener("DOMContentLoaded", function () {
|
|
68
74
|
const elem = document.getElementById("root");
|
|
@@ -77,7 +83,7 @@ export default <ITestShape extends ITTestShape>(
|
|
|
77
83
|
ndx,
|
|
78
84
|
testRsource,
|
|
79
85
|
artificer
|
|
80
|
-
): Promise<
|
|
86
|
+
): Promise<IStore> => {
|
|
81
87
|
return new Promise((resolve, rej) => {
|
|
82
88
|
const reactElement = React.createElement(TesterantoComponent, {
|
|
83
89
|
done: (reactElement) => {
|
|
@@ -92,20 +98,20 @@ export default <ITestShape extends ITTestShape>(
|
|
|
92
98
|
ReactDom.createRoot(htmlElement).render(reactElement);
|
|
93
99
|
});
|
|
94
100
|
},
|
|
95
|
-
andWhen: function (s:
|
|
101
|
+
andWhen: function (s: IStore, actioner): Promise<ISelection> {
|
|
96
102
|
return actioner()(s);
|
|
97
103
|
},
|
|
98
|
-
butThen: async function (s:
|
|
104
|
+
butThen: async function (s: IStore): Promise<ISelection> {
|
|
99
105
|
return s;
|
|
100
106
|
},
|
|
101
107
|
afterEach: async function (
|
|
102
|
-
store:
|
|
108
|
+
store: IStore,
|
|
103
109
|
ndx,
|
|
104
110
|
artificer
|
|
105
111
|
) {
|
|
106
112
|
return {};
|
|
107
113
|
},
|
|
108
|
-
afterAll: (store:
|
|
114
|
+
afterAll: (store: IStore, artificer) => {
|
|
109
115
|
return;
|
|
110
116
|
},
|
|
111
117
|
},
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
useEffect, useRef,
|
|
3
|
+
} from "react";
|
|
4
|
+
import ReactDom from "react-dom/client";
|
|
5
|
+
|
|
6
|
+
import { ITTestShape, ITestImplementation, ITestSpecification } from "../../../core";
|
|
7
|
+
import Testeranto from "../../../../src/Web";
|
|
8
|
+
|
|
9
|
+
type Input = [string, (string) => string, any];
|
|
10
|
+
type InitialState = unknown;
|
|
11
|
+
type IWhenShape = any;
|
|
12
|
+
type IThenShape = any;
|
|
13
|
+
type ISelection = IStore;
|
|
14
|
+
|
|
15
|
+
type Prototype = () => JSX.Element;
|
|
16
|
+
type IStore = {
|
|
17
|
+
root: HTMLElement,
|
|
18
|
+
react: HTMLElement,
|
|
19
|
+
};
|
|
20
|
+
type ISubject = {
|
|
21
|
+
root: HTMLElement
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default <ITestShape extends ITTestShape>(
|
|
25
|
+
testImplementations: ITestImplementation<
|
|
26
|
+
InitialState,
|
|
27
|
+
ISelection,
|
|
28
|
+
IWhenShape,
|
|
29
|
+
IThenShape,
|
|
30
|
+
ITestShape
|
|
31
|
+
>,
|
|
32
|
+
testSpecifications: ITestSpecification<
|
|
33
|
+
ITestShape,
|
|
34
|
+
ISubject,
|
|
35
|
+
IStore,
|
|
36
|
+
ISelection,
|
|
37
|
+
IThenShape
|
|
38
|
+
>,
|
|
39
|
+
testInput: Prototype
|
|
40
|
+
) => {
|
|
41
|
+
const TesterantoComponent = function (props) {
|
|
42
|
+
const myContainer = useRef(null);
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
console.log(
|
|
46
|
+
"This only happens ONCE. It happens AFTER the initial render."
|
|
47
|
+
);
|
|
48
|
+
// eslint-disable-next-line react/prop-types
|
|
49
|
+
props.done(myContainer.current);
|
|
50
|
+
}, []);
|
|
51
|
+
|
|
52
|
+
return React.createElement('div', { ref: myContainer }, testInput()); //testInput();
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return Testeranto<
|
|
56
|
+
ITestShape,
|
|
57
|
+
Prototype,
|
|
58
|
+
ISubject,
|
|
59
|
+
IStore,
|
|
60
|
+
ISelection,
|
|
61
|
+
IThenShape,
|
|
62
|
+
IWhenShape,
|
|
63
|
+
InitialState
|
|
64
|
+
>(
|
|
65
|
+
testInput,
|
|
66
|
+
testSpecifications,
|
|
67
|
+
testImplementations,
|
|
68
|
+
{
|
|
69
|
+
beforeAll: async (
|
|
70
|
+
prototype,
|
|
71
|
+
artificer
|
|
72
|
+
): Promise<ISubject> => {
|
|
73
|
+
artificer("./before.txt", "hello artificer");
|
|
74
|
+
return await new Promise((resolve, rej) => {
|
|
75
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
76
|
+
const elem = document.getElementById("root");
|
|
77
|
+
if (elem) {
|
|
78
|
+
resolve({ root: elem });
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
})
|
|
82
|
+
},
|
|
83
|
+
beforeEach: async (
|
|
84
|
+
{ root },
|
|
85
|
+
ndx,
|
|
86
|
+
testRsource,
|
|
87
|
+
artificer
|
|
88
|
+
): Promise<IStore> => {
|
|
89
|
+
return new Promise((resolve, rej) => {
|
|
90
|
+
ReactDom.createRoot(root).
|
|
91
|
+
render(
|
|
92
|
+
React.createElement(
|
|
93
|
+
TesterantoComponent, {
|
|
94
|
+
done: (react) => resolve({ root, react })
|
|
95
|
+
}, []));
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
andWhen: function (s: IStore, actioner): Promise<ISelection> {
|
|
99
|
+
return actioner()(s);
|
|
100
|
+
},
|
|
101
|
+
butThen: async function (s: IStore): Promise<ISelection> {
|
|
102
|
+
return s;
|
|
103
|
+
},
|
|
104
|
+
afterEach: async function (
|
|
105
|
+
store: IStore,
|
|
106
|
+
ndx,
|
|
107
|
+
artificer
|
|
108
|
+
) {
|
|
109
|
+
return {};
|
|
110
|
+
},
|
|
111
|
+
afterAll: (store: IStore, artificer) => {
|
|
112
|
+
// store.page.browser().close();
|
|
113
|
+
return;
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
)
|
|
117
|
+
};
|