testeranto 0.47.30 → 0.47.31
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/Node.js +13 -21
- package/dist/common/Project.js +228 -208
- package/dist/common/Web.js +59 -13
- package/dist/common/core.js +6 -1
- package/dist/common/electron.js +14 -2
- package/dist/common/preload.js +20 -0
- package/dist/common/subPackages/react/jsx/index.js +26 -0
- package/dist/common/subPackages/react/jsx/node.js +2 -11
- package/dist/common/subPackages/react/jsx/web.js +2 -11
- package/dist/common/subPackages/react-dom/component/node.js +78 -34
- package/dist/common/subPackages/react-dom/component/web.js +50 -46
- package/dist/common/subPackages/react-dom/jsx/node.js +101 -0
- package/dist/common/subPackages/react-test-renderer/component/index.js +78 -0
- package/dist/common/subPackages/react-test-renderer/component/node.js +8 -0
- package/dist/common/subPackages/react-test-renderer/component/web.js +8 -0
- package/dist/common/subPackages/{react-test-render/component/web.js → react-test-renderer/jsx/index.js} +3 -3
- package/dist/common/subPackages/react-test-renderer/jsx/node.js +10 -0
- package/dist/common/subPackages/react-test-renderer/jsx/web.js +10 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/Node.js +13 -21
- package/dist/module/Project.js +228 -208
- package/dist/module/Web.js +59 -13
- package/dist/module/core.js +6 -1
- package/dist/module/electron.js +14 -2
- package/dist/module/preload.js +20 -0
- package/dist/module/subPackages/react/jsx/index.js +22 -0
- package/dist/module/subPackages/react/jsx/node.js +2 -11
- package/dist/module/subPackages/react/jsx/web.js +2 -11
- package/dist/module/subPackages/react-dom/component/node.js +75 -34
- package/dist/module/subPackages/react-dom/component/web.js +50 -46
- package/dist/module/subPackages/react-dom/jsx/node.js +93 -0
- package/dist/module/subPackages/react-test-renderer/component/index.js +52 -0
- package/dist/module/subPackages/react-test-renderer/component/node.js +3 -0
- package/dist/module/subPackages/react-test-renderer/component/web.js +3 -0
- package/dist/module/subPackages/{react-test-render/component/web.js → react-test-renderer/jsx/index.js} +2 -3
- package/dist/module/subPackages/react-test-renderer/jsx/node.js +5 -0
- package/dist/module/subPackages/react-test-renderer/jsx/web.js +5 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/types/Project.d.ts +2 -1
- package/dist/types/core.d.ts +1 -0
- package/dist/types/subPackages/react/jsx/index.d.ts +15 -0
- package/dist/types/subPackages/react/jsx/node.d.ts +3 -10
- package/dist/types/subPackages/react/jsx/web.d.ts +3 -11
- package/dist/types/subPackages/react-dom/component/node.d.ts +9 -14
- package/dist/types/subPackages/react-dom/component/web.d.ts +1 -1
- package/dist/types/subPackages/react-dom/jsx/node.d.ts +14 -0
- package/dist/types/subPackages/react-dom/jsx/web.d.ts +0 -1
- package/dist/types/subPackages/react-test-renderer/component/index.d.ts +20 -0
- package/dist/types/subPackages/react-test-renderer/component/node.d.ts +9 -0
- package/dist/types/subPackages/react-test-renderer/component/web.d.ts +9 -0
- package/dist/types/subPackages/react-test-renderer/jsx/index.d.ts +15 -0
- package/dist/types/subPackages/react-test-renderer/jsx/node.d.ts +4 -0
- package/dist/types/subPackages/react-test-renderer/jsx/web.d.ts +4 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +67 -7
- package/src/Node.ts +18 -30
- package/src/Project.ts +292 -274
- package/src/Web.ts +78 -16
- package/src/core.ts +7 -1
- package/src/electron.ts +18 -2
- package/src/preload.ts +23 -0
- package/src/subPackages/react/jsx/index.ts +64 -0
- package/src/subPackages/react/jsx/node.ts +7 -36
- package/src/subPackages/react/jsx/web.ts +7 -38
- package/src/subPackages/react-dom/component/node.ts +85 -54
- package/src/subPackages/react-dom/component/web.ts +86 -76
- package/src/subPackages/react-dom/jsx/node.ts +150 -0
- package/src/subPackages/react-test-renderer/component/index.ts +101 -0
- package/src/subPackages/react-test-renderer/component/node.ts +30 -0
- package/src/subPackages/react-test-renderer/component/web.ts +30 -0
- package/src/subPackages/react-test-renderer/jsx/index.ts +51 -0
- package/src/subPackages/react-test-renderer/jsx/node.ts +31 -0
- package/src/subPackages/react-test-renderer/jsx/web.ts +31 -0
- package/dist/common/subPackages/react-test-render/component/node.js +0 -44
- package/dist/common/subPackages/react-test-render/jsx/node.js +0 -46
- package/dist/common/subPackages/react-test-render/jsx/web.js +0 -46
- package/dist/module/subPackages/react-test-render/component/node.js +0 -16
- package/dist/module/subPackages/react-test-render/jsx/node.js +0 -16
- package/dist/module/subPackages/react-test-render/jsx/web.js +0 -16
- package/dist/types/subPackages/react-test-render/component/node.d.ts +0 -19
- package/dist/types/subPackages/react-test-render/component/web.d.ts +0 -20
- package/dist/types/subPackages/react-test-render/jsx/node.d.ts +0 -20
- package/dist/types/subPackages/react-test-render/jsx/web.d.ts +0 -20
- package/src/subPackages/react-test-render/component/node.ts +0 -80
- package/src/subPackages/react-test-render/component/web.ts +0 -78
- package/src/subPackages/react-test-render/jsx/node.ts +0 -75
- package/src/subPackages/react-test-render/jsx/web.ts +0 -75
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { CElement } from "react";
|
|
1
|
+
import React, { CElement, createElement } from "react";
|
|
2
2
|
import ReactDom from "react-dom/client";
|
|
3
3
|
|
|
4
4
|
import { ITTestShape, ITestImplementation, ITestSpecification } from "../../../core";
|
|
@@ -39,81 +39,91 @@ export default <ITestShape extends ITTestShape>(
|
|
|
39
39
|
>,
|
|
40
40
|
testInput: IInput
|
|
41
41
|
) => {
|
|
42
|
-
class TesterantoComponent extends testInput {
|
|
43
|
-
done: (t: TesterantoComponent) => void;
|
|
44
|
-
constructor(props) {
|
|
45
|
-
super(props);
|
|
46
|
-
this.done = props.done;
|
|
47
|
-
}
|
|
48
|
-
componentDidMount() {
|
|
49
|
-
super.componentDidMount && super.componentDidMount();
|
|
50
|
-
return this.done(this);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
42
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
{
|
|
92
|
-
|
|
93
|
-
|
|
43
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
44
|
+
console.log("DOMContentLoaded")
|
|
45
|
+
const elem = document.getElementById("root");
|
|
46
|
+
if (elem) {
|
|
47
|
+
class TesterantoComponent extends testInput {
|
|
48
|
+
done: (t: TesterantoComponent) => void;
|
|
49
|
+
constructor(props) {
|
|
50
|
+
super(props);
|
|
51
|
+
this.done = props.done;
|
|
52
|
+
}
|
|
53
|
+
componentDidMount() {
|
|
54
|
+
super.componentDidMount && super.componentDidMount();
|
|
55
|
+
return this.done(this);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return Testeranto<
|
|
60
|
+
ITestShape,
|
|
61
|
+
IInput,
|
|
62
|
+
ISubject,
|
|
63
|
+
IStore,
|
|
64
|
+
ISelection,
|
|
65
|
+
IThenShape,
|
|
66
|
+
IWhenShape,
|
|
67
|
+
InitialState
|
|
68
|
+
>(
|
|
69
|
+
testInput,
|
|
70
|
+
testSpecifications,
|
|
71
|
+
testImplementations,
|
|
72
|
+
{
|
|
73
|
+
beforeAll: async (
|
|
74
|
+
prototype,
|
|
75
|
+
artificer
|
|
76
|
+
): Promise<ISubject> => {
|
|
77
|
+
return await new Promise((resolve, rej) => {
|
|
78
|
+
const elem = document.getElementById("root");
|
|
79
|
+
if (elem) {
|
|
80
|
+
resolve({ htmlElement: elem });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
})
|
|
84
|
+
},
|
|
85
|
+
beforeEach: async (
|
|
86
|
+
{ htmlElement },
|
|
87
|
+
ndx,
|
|
88
|
+
testRsource,
|
|
89
|
+
artificer
|
|
90
|
+
): Promise<IStore> => {
|
|
91
|
+
return new Promise((resolve, rej) => {
|
|
92
|
+
// Ignore these type errors
|
|
93
|
+
ReactDom.createRoot(htmlElement).render(createElement(
|
|
94
|
+
TesterantoComponent, {
|
|
95
|
+
done: (reactElement) => {
|
|
96
|
+
resolve(
|
|
97
|
+
{
|
|
98
|
+
htmlElement,
|
|
99
|
+
reactElement,
|
|
100
|
+
}
|
|
101
|
+
);
|
|
94
102
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
)
|
|
103
|
+
}, []
|
|
104
|
+
));
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
andWhen: function (s: IStore, actioner): Promise<ISelection> {
|
|
108
|
+
return actioner()(s);
|
|
109
|
+
},
|
|
110
|
+
butThen: async function (s: IStore): Promise<ISelection> {
|
|
111
|
+
return s;
|
|
112
|
+
},
|
|
113
|
+
afterEach: async function (
|
|
114
|
+
store: IStore,
|
|
115
|
+
ndx,
|
|
116
|
+
artificer
|
|
117
|
+
) {
|
|
118
|
+
return {};
|
|
119
|
+
},
|
|
120
|
+
afterAll: (store: IStore, artificer) => {
|
|
121
|
+
return;
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
|
|
119
129
|
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import React, { ReactNode, createElement } from "react";
|
|
2
|
+
import { renderToStaticMarkup, renderToStaticNodeStream } from "react-dom/server";
|
|
3
|
+
import Stream from 'stream'
|
|
4
|
+
|
|
5
|
+
import { ITTestShape, ITestImplementation, ITestSpecification } from "../../../core";
|
|
6
|
+
import Testeranto from "../../../Node";
|
|
7
|
+
|
|
8
|
+
export type IInput = () => JSX.Element;
|
|
9
|
+
type InitialState = unknown;
|
|
10
|
+
type IWhenShape = any;
|
|
11
|
+
export type IThenShape = any;
|
|
12
|
+
export type ISelection = ReactNode;
|
|
13
|
+
export type IStore = ReactNode;
|
|
14
|
+
export type ISubject = ReactNode;
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
renderToStaticMarkup, renderToStaticNodeStream, Stream
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default <ITestShape extends ITTestShape>(
|
|
21
|
+
testImplementations: ITestImplementation<
|
|
22
|
+
InitialState,
|
|
23
|
+
ISelection,
|
|
24
|
+
IWhenShape,
|
|
25
|
+
IThenShape,
|
|
26
|
+
ITestShape
|
|
27
|
+
>,
|
|
28
|
+
testSpecifications: ITestSpecification<
|
|
29
|
+
ITestShape,
|
|
30
|
+
ISubject,
|
|
31
|
+
IStore,
|
|
32
|
+
ISelection,
|
|
33
|
+
IThenShape
|
|
34
|
+
>,
|
|
35
|
+
testInput: IInput
|
|
36
|
+
) => {
|
|
37
|
+
return Testeranto<
|
|
38
|
+
ITestShape,
|
|
39
|
+
IInput,
|
|
40
|
+
ISubject,
|
|
41
|
+
IStore,
|
|
42
|
+
ISelection,
|
|
43
|
+
IThenShape,
|
|
44
|
+
IWhenShape,
|
|
45
|
+
InitialState
|
|
46
|
+
>(
|
|
47
|
+
testInput,
|
|
48
|
+
testSpecifications,
|
|
49
|
+
testImplementations,
|
|
50
|
+
{
|
|
51
|
+
// beforeAll: async (
|
|
52
|
+
// prototype,
|
|
53
|
+
// artificer
|
|
54
|
+
// ): Promise<ISubject> => {
|
|
55
|
+
// return await new Promise((resolve, rej) => {
|
|
56
|
+
// const elem = document.getElementById("root");
|
|
57
|
+
// if (elem) {
|
|
58
|
+
// resolve({ htmlElement: elem });
|
|
59
|
+
// }
|
|
60
|
+
|
|
61
|
+
// })
|
|
62
|
+
// },
|
|
63
|
+
beforeEach: async (
|
|
64
|
+
reactComponent,
|
|
65
|
+
ndx,
|
|
66
|
+
testRsource,
|
|
67
|
+
artificer
|
|
68
|
+
): Promise<IStore> => {
|
|
69
|
+
return new Promise((resolve, rej) => {
|
|
70
|
+
// Ignore these type errors
|
|
71
|
+
resolve(createElement(testInput));
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
andWhen: async function (s: IStore, actioner): Promise<ISelection> {
|
|
75
|
+
// return actioner()(s);
|
|
76
|
+
return s
|
|
77
|
+
},
|
|
78
|
+
butThen: async function (s: IStore): Promise<ISelection> {
|
|
79
|
+
return s;
|
|
80
|
+
},
|
|
81
|
+
afterEach: async function (
|
|
82
|
+
store: IStore,
|
|
83
|
+
ndx,
|
|
84
|
+
artificer
|
|
85
|
+
) {
|
|
86
|
+
return {};
|
|
87
|
+
},
|
|
88
|
+
afterAll: (store: IStore, artificer) => {
|
|
89
|
+
return;
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
)
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
// type IInput = typeof React.Component;
|
|
97
|
+
// type InitialState = unknown;
|
|
98
|
+
// type IWhenShape = any;
|
|
99
|
+
// type IThenShape = any;
|
|
100
|
+
// type ISelection = string;
|
|
101
|
+
// type IStore = string;
|
|
102
|
+
// type ISubject = string
|
|
103
|
+
|
|
104
|
+
// export default <ITestShape extends ITTestShape>(
|
|
105
|
+
// testImplementations: ITestImplementation<
|
|
106
|
+
// InitialState,
|
|
107
|
+
// ISelection,
|
|
108
|
+
// IWhenShape,
|
|
109
|
+
// IThenShape,
|
|
110
|
+
// ITestShape
|
|
111
|
+
// >,
|
|
112
|
+
// testSpecifications: ITestSpecification<
|
|
113
|
+
// ITestShape,
|
|
114
|
+
// ISubject,
|
|
115
|
+
// IStore,
|
|
116
|
+
// ISelection,
|
|
117
|
+
// IThenShape
|
|
118
|
+
// >,
|
|
119
|
+
// testInput: IInput
|
|
120
|
+
// ) => {
|
|
121
|
+
// return Testeranto<
|
|
122
|
+
// ITestShape,
|
|
123
|
+
// IInput,
|
|
124
|
+
// ISubject,
|
|
125
|
+
// IStore,
|
|
126
|
+
// ISelection,
|
|
127
|
+
// IThenShape,
|
|
128
|
+
// IWhenShape,
|
|
129
|
+
// InitialState
|
|
130
|
+
// >(
|
|
131
|
+
// testInput,
|
|
132
|
+
// testSpecifications,
|
|
133
|
+
// testImplementations,
|
|
134
|
+
// {
|
|
135
|
+
// beforeEach: async (
|
|
136
|
+
// element,
|
|
137
|
+
// ndx,
|
|
138
|
+
// testResource,
|
|
139
|
+
// artificer
|
|
140
|
+
// ): Promise<IStore> => {
|
|
141
|
+
// return new Promise((resolve, rej) => {
|
|
142
|
+
// resolve(ReactDOMServer.renderToStaticMarkup(element));
|
|
143
|
+
// });
|
|
144
|
+
// },
|
|
145
|
+
// andWhen: function (s: IStore, actioner): Promise<ISelection> {
|
|
146
|
+
// throw new Error(`"andWhens" are not permitted`);
|
|
147
|
+
// }
|
|
148
|
+
// },
|
|
149
|
+
// )
|
|
150
|
+
// };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import renderer, { act } from "react-test-renderer";
|
|
3
|
+
|
|
4
|
+
import { ITTestShape, ITestImplementation, ITestSpecification } from "../../../core";
|
|
5
|
+
|
|
6
|
+
export type ISuper<T> = T extends infer U ? U : object;
|
|
7
|
+
|
|
8
|
+
// export type IInput<P, S> = React.Component<P, S>
|
|
9
|
+
export type IInput<P, S> = typeof React.Component<P, S>;
|
|
10
|
+
export type InitialState = unknown;
|
|
11
|
+
export type IWhenShape = any;
|
|
12
|
+
export type IThenShape = any;
|
|
13
|
+
export type ISelection = renderer.ReactTestRenderer;
|
|
14
|
+
export type IStore = renderer.ReactTestRenderer;
|
|
15
|
+
export type ISubject = renderer.ReactTestRenderer;
|
|
16
|
+
|
|
17
|
+
export type IImpl<
|
|
18
|
+
ITestShape extends ITTestShape,
|
|
19
|
+
IProps
|
|
20
|
+
> = ITestImplementation<
|
|
21
|
+
IProps,
|
|
22
|
+
renderer.ReactTestRenderer,
|
|
23
|
+
IWhenShape,
|
|
24
|
+
IThenShape,
|
|
25
|
+
ITestShape
|
|
26
|
+
>
|
|
27
|
+
export type ISpec<
|
|
28
|
+
ITestShape extends ITTestShape
|
|
29
|
+
> = ITestSpecification<
|
|
30
|
+
ITestShape,
|
|
31
|
+
ISubject,
|
|
32
|
+
IStore,
|
|
33
|
+
ISelection,
|
|
34
|
+
IThenShape
|
|
35
|
+
>
|
|
36
|
+
|
|
37
|
+
// export const testInterface = {
|
|
38
|
+
// beforeEach: function (CComponent, props): Promise<renderer.ReactTestRenderer> {
|
|
39
|
+
// return new Promise((res, rej) => {
|
|
40
|
+
// let component: renderer.ReactTestRenderer;
|
|
41
|
+
// act(() => {
|
|
42
|
+
// component = renderer.create(
|
|
43
|
+
// CComponent(props)
|
|
44
|
+
// );
|
|
45
|
+
// res(component);
|
|
46
|
+
// });
|
|
47
|
+
// });
|
|
48
|
+
// },
|
|
49
|
+
// andWhen: async function (
|
|
50
|
+
// renderer: renderer.ReactTestRenderer,
|
|
51
|
+
// actioner: () => (any) => any
|
|
52
|
+
// ): Promise<renderer.ReactTestRenderer> {
|
|
53
|
+
// await act(() => actioner()(renderer));
|
|
54
|
+
// return renderer
|
|
55
|
+
// }
|
|
56
|
+
// }
|
|
57
|
+
|
|
58
|
+
export const testInterface = {
|
|
59
|
+
beforeEach: function (CComponent, props): Promise<renderer.ReactTestRenderer> {
|
|
60
|
+
|
|
61
|
+
return new Promise((res, rej) => {
|
|
62
|
+
act(() => {
|
|
63
|
+
const x = renderer.create(new CComponent(props));
|
|
64
|
+
console.log("beforeEach", x.getInstance())
|
|
65
|
+
res(x);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
andWhen: async function (
|
|
70
|
+
renderer: renderer.ReactTestRenderer,
|
|
71
|
+
actioner: any
|
|
72
|
+
): Promise<renderer.ReactTestRenderer> {
|
|
73
|
+
// console.log("andWhen", renderer)
|
|
74
|
+
await act(() => actioner()(renderer));
|
|
75
|
+
return renderer
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
// andWhen: function (s: Store, actioner): Promise<Selection> {
|
|
79
|
+
// return actioner()(s);
|
|
80
|
+
// },
|
|
81
|
+
butThen: async function (s: IStore): Promise<ISelection> {
|
|
82
|
+
|
|
83
|
+
// console.log("butThen", s)
|
|
84
|
+
return s;
|
|
85
|
+
},
|
|
86
|
+
afterEach: async function (
|
|
87
|
+
store: IStore,
|
|
88
|
+
ndx,
|
|
89
|
+
artificer
|
|
90
|
+
) {
|
|
91
|
+
// console.log("afterEach", store);
|
|
92
|
+
return {
|
|
93
|
+
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
afterAll: (store: IStore, artificer) => {
|
|
97
|
+
// console.log("afterAll", store);
|
|
98
|
+
return;
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Testeranto from "../../../Node";
|
|
2
|
+
|
|
3
|
+
import { ITTestShape } from "../../../core";
|
|
4
|
+
|
|
5
|
+
import { IImpl, ISpec, IInput, testInterface } from ".";
|
|
6
|
+
|
|
7
|
+
export default <
|
|
8
|
+
ITestShape extends ITTestShape,
|
|
9
|
+
IProps,
|
|
10
|
+
IState
|
|
11
|
+
>(
|
|
12
|
+
testImplementations: IImpl<ITestShape, IProps>,
|
|
13
|
+
testSpecifications: ISpec<ITestShape>,
|
|
14
|
+
testInput: IInput<IProps, IState>,
|
|
15
|
+
) =>
|
|
16
|
+
Testeranto<
|
|
17
|
+
ITestShape,
|
|
18
|
+
IInput<IProps, IState>,
|
|
19
|
+
any,
|
|
20
|
+
any,
|
|
21
|
+
any,
|
|
22
|
+
any,
|
|
23
|
+
any,
|
|
24
|
+
any
|
|
25
|
+
>(
|
|
26
|
+
testInput,
|
|
27
|
+
testSpecifications,
|
|
28
|
+
testImplementations,
|
|
29
|
+
testInterface
|
|
30
|
+
)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Testeranto from "../../../Web";
|
|
2
|
+
|
|
3
|
+
import { ITTestShape } from "../../../core";
|
|
4
|
+
|
|
5
|
+
import { IImpl, ISpec, IInput, testInterface } from ".";
|
|
6
|
+
|
|
7
|
+
export default <
|
|
8
|
+
ITestShape extends ITTestShape,
|
|
9
|
+
IProps,
|
|
10
|
+
IState
|
|
11
|
+
>(
|
|
12
|
+
testImplementations: IImpl<ITestShape, IProps>,
|
|
13
|
+
testSpecifications: ISpec<ITestShape>,
|
|
14
|
+
testInput: IInput<IProps, IState>,
|
|
15
|
+
) =>
|
|
16
|
+
Testeranto<
|
|
17
|
+
ITestShape,
|
|
18
|
+
IInput<IProps, IState>,
|
|
19
|
+
any,
|
|
20
|
+
any,
|
|
21
|
+
any,
|
|
22
|
+
any,
|
|
23
|
+
any,
|
|
24
|
+
any
|
|
25
|
+
>(
|
|
26
|
+
testInput,
|
|
27
|
+
testSpecifications,
|
|
28
|
+
testImplementations,
|
|
29
|
+
testInterface
|
|
30
|
+
)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import renderer, { act } from "react-test-renderer";
|
|
3
|
+
|
|
4
|
+
import { ITTestShape, ITestImplementation, ITestSpecification } from "../../../core";
|
|
5
|
+
|
|
6
|
+
export type IWhenShape = any;
|
|
7
|
+
export type IThenShape = any;
|
|
8
|
+
export type InitialState = unknown;
|
|
9
|
+
export type IInput = () => JSX.Element;
|
|
10
|
+
export type ISelection = renderer.ReactTestRenderer;
|
|
11
|
+
export type IStore = renderer.ReactTestRenderer;
|
|
12
|
+
export type ISubject = renderer.ReactTestRenderer;
|
|
13
|
+
|
|
14
|
+
export type ITestImpl<
|
|
15
|
+
ITestShape extends ITTestShape
|
|
16
|
+
> = ITestImplementation<
|
|
17
|
+
InitialState,
|
|
18
|
+
ISelection,
|
|
19
|
+
IWhenShape,
|
|
20
|
+
IThenShape,
|
|
21
|
+
ITestShape
|
|
22
|
+
>
|
|
23
|
+
|
|
24
|
+
export type ITestSpec<
|
|
25
|
+
ITestShape extends ITTestShape
|
|
26
|
+
> = ITestSpecification<
|
|
27
|
+
ITestShape,
|
|
28
|
+
ISubject,
|
|
29
|
+
IStore,
|
|
30
|
+
ISelection,
|
|
31
|
+
IThenShape
|
|
32
|
+
>
|
|
33
|
+
|
|
34
|
+
export const testInterface = {
|
|
35
|
+
beforeEach: function (CComponent, props): Promise<renderer.ReactTestRenderer> {
|
|
36
|
+
let component;
|
|
37
|
+
act(() => {
|
|
38
|
+
component = renderer.create(
|
|
39
|
+
React.createElement(CComponent, props, [])
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
return component;
|
|
43
|
+
},
|
|
44
|
+
andWhen: async function (
|
|
45
|
+
renderer: renderer.ReactTestRenderer,
|
|
46
|
+
actioner: () => (any) => any
|
|
47
|
+
): Promise<renderer.ReactTestRenderer> {
|
|
48
|
+
await act(() => actioner()(renderer));
|
|
49
|
+
return renderer
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import test from "../../../Node";
|
|
2
|
+
|
|
3
|
+
import { ITTestShape } from "../../../core";
|
|
4
|
+
|
|
5
|
+
import { testInterface } from "./index";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
ITestImpl, ITestSpec, IInput, ISubject, IStore, ISelection, IThenShape, IWhenShape, InitialState
|
|
9
|
+
} from ".";
|
|
10
|
+
|
|
11
|
+
export default <ITestShape extends ITTestShape>(
|
|
12
|
+
testImplementations: ITestImpl<ITestShape>,
|
|
13
|
+
testSpecifications: ITestSpec<ITestShape>,
|
|
14
|
+
testInput: IInput
|
|
15
|
+
) => {
|
|
16
|
+
return test<
|
|
17
|
+
ITestShape,
|
|
18
|
+
IInput,
|
|
19
|
+
ISubject,
|
|
20
|
+
IStore,
|
|
21
|
+
ISelection,
|
|
22
|
+
IThenShape,
|
|
23
|
+
IWhenShape,
|
|
24
|
+
InitialState
|
|
25
|
+
>(
|
|
26
|
+
testInput,
|
|
27
|
+
testSpecifications,
|
|
28
|
+
testImplementations,
|
|
29
|
+
testInterface,
|
|
30
|
+
)
|
|
31
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import test from "../../../Web";
|
|
2
|
+
|
|
3
|
+
import { ITTestShape } from "../../../core";
|
|
4
|
+
|
|
5
|
+
import { testInterface } from "./index";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
ITestImpl, ITestSpec, IInput, ISubject, IStore, ISelection, IThenShape, IWhenShape, InitialState
|
|
9
|
+
} from ".";
|
|
10
|
+
|
|
11
|
+
export default <ITestShape extends ITTestShape>(
|
|
12
|
+
testImplementations: ITestImpl<ITestShape>,
|
|
13
|
+
testSpecifications: ITestSpec<ITestShape>,
|
|
14
|
+
testInput: IInput
|
|
15
|
+
) => {
|
|
16
|
+
return test<
|
|
17
|
+
ITestShape,
|
|
18
|
+
IInput,
|
|
19
|
+
ISubject,
|
|
20
|
+
IStore,
|
|
21
|
+
ISelection,
|
|
22
|
+
IThenShape,
|
|
23
|
+
IWhenShape,
|
|
24
|
+
InitialState
|
|
25
|
+
>(
|
|
26
|
+
testInput,
|
|
27
|
+
testSpecifications,
|
|
28
|
+
testImplementations,
|
|
29
|
+
testInterface,
|
|
30
|
+
)
|
|
31
|
+
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const react_1 = __importDefault(require("react"));
|
|
30
|
-
const react_test_renderer_1 = __importStar(require("react-test-renderer"));
|
|
31
|
-
const Node_1 = __importDefault(require("../../../Node"));
|
|
32
|
-
exports.default = (testImplementations, testSpecifications, testInput) => (0, Node_1.default)(testInput, testSpecifications, testImplementations, {
|
|
33
|
-
beforeEach: function (CComponent, props) {
|
|
34
|
-
let component;
|
|
35
|
-
(0, react_test_renderer_1.act)(() => {
|
|
36
|
-
component = react_test_renderer_1.default.create(react_1.default.createElement(CComponent, props, []));
|
|
37
|
-
});
|
|
38
|
-
return component;
|
|
39
|
-
},
|
|
40
|
-
andWhen: async function (renderer, actioner) {
|
|
41
|
-
await (0, react_test_renderer_1.act)(() => actioner()(renderer));
|
|
42
|
-
return renderer;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.ReactTestRendererTesteranto = void 0;
|
|
30
|
-
const react_1 = __importDefault(require("react"));
|
|
31
|
-
const react_test_renderer_1 = __importStar(require("react-test-renderer"));
|
|
32
|
-
const Web_1 = __importDefault(require("../../../Web"));
|
|
33
|
-
const ReactTestRendererTesteranto = (testImplementations, testSpecifications, testInput) => (0, Web_1.default)(testInput, testSpecifications, testImplementations, {
|
|
34
|
-
beforeEach: function (CComponent, props) {
|
|
35
|
-
let component;
|
|
36
|
-
(0, react_test_renderer_1.act)(() => {
|
|
37
|
-
component = react_test_renderer_1.default.create(react_1.default.createElement(CComponent, props, []));
|
|
38
|
-
});
|
|
39
|
-
return component;
|
|
40
|
-
},
|
|
41
|
-
andWhen: async function (renderer, actioner) {
|
|
42
|
-
await (0, react_test_renderer_1.act)(() => actioner()(renderer));
|
|
43
|
-
return renderer;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
exports.ReactTestRendererTesteranto = ReactTestRendererTesteranto;
|