testeranto 0.47.29 → 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/node.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/node.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 +68 -8
- 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/web.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/web.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 -20
- 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 -78
- 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
package/src/Web.ts
CHANGED
|
@@ -8,11 +8,23 @@ import {
|
|
|
8
8
|
defaultTestResourceRequirement,
|
|
9
9
|
} from "./core";
|
|
10
10
|
import TesterantoLevelTwo from "./core";
|
|
11
|
-
// import { ipcRenderer } from "electron";
|
|
12
11
|
|
|
13
12
|
const webSocket = new WebSocket("ws://localhost:8080");
|
|
14
13
|
|
|
15
|
-
const
|
|
14
|
+
const receiveTestResourceConfigUnscheduled = async (t, testresource) => {
|
|
15
|
+
const {
|
|
16
|
+
failed,
|
|
17
|
+
artifacts,
|
|
18
|
+
logPromise
|
|
19
|
+
} = await t.receiveTestResourceConfig(testresource);
|
|
20
|
+
|
|
21
|
+
Promise.all([...artifacts, logPromise]).then(async () => {
|
|
22
|
+
// ipcRenderer.invoke('quit-app', failed);
|
|
23
|
+
(window as any).exit(failed)
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const receiveTestResourceConfigScheduled = async (t, testresource) => {
|
|
16
28
|
const {
|
|
17
29
|
failed,
|
|
18
30
|
artifacts,
|
|
@@ -120,17 +132,12 @@ export default async <
|
|
|
120
132
|
testResourceArg
|
|
121
133
|
) as ITTestResourceConfiguration;
|
|
122
134
|
|
|
123
|
-
|
|
124
|
-
receiveTestResourceConfig(t, partialTestResource);
|
|
125
|
-
|
|
135
|
+
console.log("initial test resource", partialTestResource);
|
|
126
136
|
|
|
127
|
-
|
|
128
|
-
console.log("test
|
|
129
|
-
console.log(
|
|
130
|
-
"requesting test resources via ws",
|
|
131
|
-
testResourceRequirement
|
|
132
|
-
);
|
|
137
|
+
if (partialTestResource.scheduled) {
|
|
138
|
+
console.log("test is scheduled");
|
|
133
139
|
|
|
140
|
+
console.log("awaiting test resources via WS...");
|
|
134
141
|
webSocket.addEventListener("open", (event) => {
|
|
135
142
|
webSocket.addEventListener("message", (event) => {
|
|
136
143
|
console.log("Message from server ", event.data);
|
|
@@ -139,7 +146,10 @@ export default async <
|
|
|
139
146
|
const r = JSON.stringify({
|
|
140
147
|
type: "testeranto:hola",
|
|
141
148
|
data: {
|
|
142
|
-
|
|
149
|
+
requirement: {
|
|
150
|
+
...testResourceRequirement,
|
|
151
|
+
name: partialTestResource.name
|
|
152
|
+
}
|
|
143
153
|
},
|
|
144
154
|
});
|
|
145
155
|
|
|
@@ -150,20 +160,72 @@ export default async <
|
|
|
150
160
|
async (msg: MessageEvent<any>) => {
|
|
151
161
|
console.log("message: ", msg);
|
|
152
162
|
|
|
153
|
-
const
|
|
163
|
+
const resourcesFromWs = JSON.parse(msg.data);
|
|
164
|
+
console.log("secondary test resource", resourcesFromWs);
|
|
165
|
+
|
|
154
166
|
const secondTestResource = {
|
|
155
167
|
fs: ".",
|
|
156
168
|
...JSON.parse(JSON.stringify(partialTestResource)),
|
|
157
|
-
...JSON.parse(JSON.stringify(
|
|
169
|
+
...JSON.parse(JSON.stringify(resourcesFromWs)),
|
|
158
170
|
} as ITTestResourceConfiguration;
|
|
159
171
|
|
|
160
|
-
console.log("
|
|
161
|
-
|
|
172
|
+
console.log("final test resource", secondTestResource);
|
|
173
|
+
receiveTestResourceConfigScheduled(t, secondTestResource);
|
|
162
174
|
}
|
|
163
175
|
);
|
|
164
176
|
});
|
|
177
|
+
} else {
|
|
178
|
+
receiveTestResourceConfigUnscheduled(t, partialTestResource);
|
|
165
179
|
}
|
|
166
180
|
|
|
181
|
+
// const partialTestResource = JSON.parse(
|
|
182
|
+
// testResourceArg
|
|
183
|
+
// ) as ITTestResourceConfiguration;
|
|
184
|
+
|
|
185
|
+
// if (partialTestResource.fs && partialTestResource.ports) {
|
|
186
|
+
// receiveTestResourceConfig(t, partialTestResource);
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
// } else {
|
|
190
|
+
// console.log("test configuration is incomplete", partialTestResource);
|
|
191
|
+
// console.log(
|
|
192
|
+
// "requesting test resources via ws",
|
|
193
|
+
// testResourceRequirement
|
|
194
|
+
// );
|
|
195
|
+
|
|
196
|
+
// webSocket.addEventListener("open", (event) => {
|
|
197
|
+
// webSocket.addEventListener("message", (event) => {
|
|
198
|
+
// console.log("Message from server ", event.data);
|
|
199
|
+
// });
|
|
200
|
+
|
|
201
|
+
// const r = JSON.stringify({
|
|
202
|
+
// type: "testeranto:hola",
|
|
203
|
+
// data: {
|
|
204
|
+
// testResourceRequirement,
|
|
205
|
+
// },
|
|
206
|
+
// });
|
|
207
|
+
|
|
208
|
+
// webSocket.send(r);
|
|
209
|
+
|
|
210
|
+
// console.log("awaiting test resources via websocket...", r);
|
|
211
|
+
// webSocket.onmessage = (
|
|
212
|
+
// async (msg: MessageEvent<any>) => {
|
|
213
|
+
// console.log("message: ", msg);
|
|
214
|
+
|
|
215
|
+
// const resourcesFromPm2 = msg.data.testResourceConfiguration;
|
|
216
|
+
// const secondTestResource = {
|
|
217
|
+
// fs: ".",
|
|
218
|
+
// ...JSON.parse(JSON.stringify(partialTestResource)),
|
|
219
|
+
// ...JSON.parse(JSON.stringify(resourcesFromPm2)),
|
|
220
|
+
// } as ITTestResourceConfiguration;
|
|
221
|
+
|
|
222
|
+
// console.log("secondTestResource", secondTestResource);
|
|
223
|
+
// receiveTestResourceConfig(t, secondTestResource);
|
|
224
|
+
// }
|
|
225
|
+
// );
|
|
226
|
+
// });
|
|
227
|
+
// }
|
|
228
|
+
|
|
167
229
|
} catch (e) {
|
|
168
230
|
console.error(e);
|
|
169
231
|
// process.exit(-1);
|
package/src/core.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
const defaultTestResource: ITTestResourceConfiguration = {
|
|
1
|
+
const defaultTestResource: ITTestResourceConfiguration = {
|
|
2
|
+
name: "",
|
|
3
|
+
fs: ".",
|
|
4
|
+
ports: [],
|
|
5
|
+
scheduled: false
|
|
6
|
+
};
|
|
2
7
|
|
|
3
8
|
export type IImplementer<IImplementation> = {
|
|
4
9
|
name: string;
|
|
@@ -10,6 +15,7 @@ export type ITTestResourceConfiguration = {
|
|
|
10
15
|
name: string;
|
|
11
16
|
fs: string;
|
|
12
17
|
ports: number[];
|
|
18
|
+
scheduled: boolean;
|
|
13
19
|
};
|
|
14
20
|
|
|
15
21
|
export type ITTestResourceRequirement = {
|
package/src/electron.ts
CHANGED
|
@@ -18,7 +18,7 @@ function createWindow() {
|
|
|
18
18
|
},
|
|
19
19
|
width: 800,
|
|
20
20
|
height: 600,
|
|
21
|
-
|
|
21
|
+
show: false,
|
|
22
22
|
});
|
|
23
23
|
const u = url.format({
|
|
24
24
|
pathname: path.join(process.cwd(), process.argv[2]),
|
|
@@ -35,9 +35,25 @@ function createWindow() {
|
|
|
35
35
|
|
|
36
36
|
app.on("ready", createWindow);
|
|
37
37
|
|
|
38
|
+
ipcMain.handle('web-log', (x, message: string) => {
|
|
39
|
+
console.log("web-log)", message);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
ipcMain.handle('web-error', (x, message: string) => {
|
|
43
|
+
console.log("web-error)", message);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
ipcMain.handle('web-warn', (x, message: string) => {
|
|
47
|
+
console.log("web-warn)", message);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
ipcMain.handle('web-info', (x, message: string) => {
|
|
51
|
+
console.log("web-info)", message);
|
|
52
|
+
});
|
|
53
|
+
|
|
38
54
|
ipcMain.handle('quit-app', (x, failed: number) => {
|
|
39
55
|
console.log("quit-app", failed);
|
|
40
|
-
|
|
56
|
+
app.exit(failed);
|
|
41
57
|
});
|
|
42
58
|
|
|
43
59
|
export { };
|
package/src/preload.ts
CHANGED
|
@@ -6,3 +6,26 @@ import { ipcRenderer } from "electron";
|
|
|
6
6
|
ipcRenderer.invoke('quit-app', x);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
var oldLog = console.log;
|
|
10
|
+
console.log = function (message) {
|
|
11
|
+
ipcRenderer.invoke('web-log', message);
|
|
12
|
+
oldLog.apply(console, arguments);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
var oldLog = console.error;
|
|
16
|
+
console.error = function (message) {
|
|
17
|
+
ipcRenderer.invoke('web-error', message);
|
|
18
|
+
oldLog.apply(console, arguments);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
var oldLog = console.warn;
|
|
22
|
+
console.warn = function (message) {
|
|
23
|
+
ipcRenderer.invoke('web-warn', message);
|
|
24
|
+
oldLog.apply(console, arguments);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
var oldLog = console.info;
|
|
28
|
+
console.info = function (message) {
|
|
29
|
+
ipcRenderer.invoke('web-info', message);
|
|
30
|
+
oldLog.apply(console, arguments);
|
|
31
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { CElement, useEffect, useRef } from "react";
|
|
2
|
+
import React from "react";
|
|
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 = CElement<any, any>
|
|
11
|
+
export type IStore = CElement<any, any>
|
|
12
|
+
export type ISubject = CElement<any, any>
|
|
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
|
+
// const TesterantoComponent = (testInput) => (props) => {
|
|
35
|
+
// const myContainer = useRef(null);
|
|
36
|
+
|
|
37
|
+
// useEffect(() => {
|
|
38
|
+
// console.log(
|
|
39
|
+
// "useeffectCalled"
|
|
40
|
+
// );
|
|
41
|
+
|
|
42
|
+
// props.done(myContainer.current);
|
|
43
|
+
// }, []);
|
|
44
|
+
|
|
45
|
+
// return React.createElement('div', { ref: myContainer }, testInput()); //testInput();
|
|
46
|
+
// };
|
|
47
|
+
|
|
48
|
+
export const testInterface = (testInput) => {
|
|
49
|
+
return {
|
|
50
|
+
beforeEach: async (
|
|
51
|
+
x,
|
|
52
|
+
ndx,
|
|
53
|
+
testRsource,
|
|
54
|
+
artificer
|
|
55
|
+
): Promise<IStore> => {
|
|
56
|
+
return new Promise((resolve, rej) => {
|
|
57
|
+
resolve(testInput())
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
andWhen: function (s: IStore, actioner): Promise<ISelection> {
|
|
61
|
+
return actioner()(s);
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -1,32 +1,14 @@
|
|
|
1
|
-
import React, { CElement } from "react";
|
|
2
|
-
|
|
3
|
-
import { ITTestShape, ITestImplementation, ITestSpecification } from "../../../core";
|
|
4
1
|
import Testeranto from "../../../Node";
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
type IThenShape = any;
|
|
3
|
+
import { ITTestShape } from "../../../core";
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type IStore = CElement<any, any>
|
|
13
|
-
type ISubject = CElement<any, any>
|
|
5
|
+
import {
|
|
6
|
+
ITestImpl, ITestSpec, IInput, ISubject, IStore, ISelection, IThenShape, IWhenShape, InitialState, testInterface
|
|
7
|
+
} from ".";
|
|
14
8
|
|
|
15
9
|
export default <ITestShape extends ITTestShape>(
|
|
16
|
-
testImplementations:
|
|
17
|
-
|
|
18
|
-
ISelection,
|
|
19
|
-
IWhenShape,
|
|
20
|
-
IThenShape,
|
|
21
|
-
ITestShape
|
|
22
|
-
>,
|
|
23
|
-
testSpecifications: ITestSpecification<
|
|
24
|
-
ITestShape,
|
|
25
|
-
ISubject,
|
|
26
|
-
IStore,
|
|
27
|
-
ISelection,
|
|
28
|
-
IThenShape
|
|
29
|
-
>,
|
|
10
|
+
testImplementations: ITestImpl<ITestShape>,
|
|
11
|
+
testSpecifications: ITestSpec<ITestShape>,
|
|
30
12
|
testInput: IInput
|
|
31
13
|
) => {
|
|
32
14
|
return Testeranto<
|
|
@@ -42,17 +24,6 @@ export default <ITestShape extends ITTestShape>(
|
|
|
42
24
|
testInput,
|
|
43
25
|
testSpecifications,
|
|
44
26
|
testImplementations,
|
|
45
|
-
|
|
46
|
-
beforeEach: async (
|
|
47
|
-
): Promise<IStore> => {
|
|
48
|
-
return new Promise((resolve, rej) => {
|
|
49
|
-
resolve(React.createElement(testInput, {
|
|
50
|
-
}, []));
|
|
51
|
-
});
|
|
52
|
-
},
|
|
53
|
-
andWhen: function (s: IStore, actioner): Promise<ISelection> {
|
|
54
|
-
return actioner()(s);
|
|
55
|
-
},
|
|
56
|
-
},
|
|
27
|
+
testInterface(testInput),
|
|
57
28
|
)
|
|
58
29
|
};
|
|
@@ -1,34 +1,14 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import { ITTestShape, ITestImplementation, ITestSpecification } from "../../../core";
|
|
4
1
|
import Testeranto from "../../../Web";
|
|
5
2
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
type IWhenShape = any;
|
|
9
|
-
type IThenShape = any;
|
|
3
|
+
import { ITTestShape } from "../../../core";
|
|
10
4
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
type IStore = CElement<any, any>
|
|
15
|
-
type ISubject = CElement<any, any>
|
|
5
|
+
import {
|
|
6
|
+
ITestImpl, ITestSpec, IInput, ISubject, IStore, ISelection, IThenShape, IWhenShape, InitialState, testInterface
|
|
7
|
+
} from ".";
|
|
16
8
|
|
|
17
9
|
export default <ITestShape extends ITTestShape>(
|
|
18
|
-
testImplementations:
|
|
19
|
-
|
|
20
|
-
ISelection,
|
|
21
|
-
IWhenShape,
|
|
22
|
-
IThenShape,
|
|
23
|
-
ITestShape
|
|
24
|
-
>,
|
|
25
|
-
testSpecifications: ITestSpecification<
|
|
26
|
-
ITestShape,
|
|
27
|
-
ISubject,
|
|
28
|
-
IStore,
|
|
29
|
-
ISelection,
|
|
30
|
-
IThenShape
|
|
31
|
-
>,
|
|
10
|
+
testImplementations: ITestImpl<ITestShape>,
|
|
11
|
+
testSpecifications: ITestSpec<ITestShape>,
|
|
32
12
|
testInput: IInput
|
|
33
13
|
) => {
|
|
34
14
|
return Testeranto<
|
|
@@ -44,17 +24,6 @@ export default <ITestShape extends ITTestShape>(
|
|
|
44
24
|
testInput,
|
|
45
25
|
testSpecifications,
|
|
46
26
|
testImplementations,
|
|
47
|
-
|
|
48
|
-
beforeEach: async (
|
|
49
|
-
): Promise<IStore> => {
|
|
50
|
-
return new Promise((resolve, rej) => {
|
|
51
|
-
resolve(React.createElement(testInput, {
|
|
52
|
-
}, []));
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
andWhen: function (s: IStore, actioner): Promise<ISelection> {
|
|
56
|
-
return actioner()(s);
|
|
57
|
-
},
|
|
58
|
-
},
|
|
27
|
+
testInterface(testInput),
|
|
59
28
|
)
|
|
60
29
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import
|
|
1
|
+
import React, { ReactNode, createElement } from "react";
|
|
2
|
+
import { renderToStaticMarkup, renderToStaticNodeStream } from "react-dom/server";
|
|
3
|
+
import Stream from 'stream'
|
|
3
4
|
|
|
4
5
|
import { ITTestShape, ITestImplementation, ITestSpecification } from "../../../core";
|
|
5
6
|
import Testeranto from "../../../Node";
|
|
@@ -7,20 +8,14 @@ import Testeranto from "../../../Node";
|
|
|
7
8
|
type IInput = typeof React.Component;
|
|
8
9
|
type InitialState = unknown;
|
|
9
10
|
type IWhenShape = any;
|
|
10
|
-
type IThenShape = any;
|
|
11
|
-
type ISelection =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type IStore = {
|
|
17
|
-
htmlElement: HTMLElement,
|
|
18
|
-
reactElement: CElement<any, any>,
|
|
19
|
-
};
|
|
11
|
+
export type IThenShape = any;
|
|
12
|
+
export type ISelection = ReactNode;
|
|
13
|
+
export type IStore = ReactNode;
|
|
14
|
+
export type ISubject = ReactNode;
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
16
|
+
export {
|
|
17
|
+
renderToStaticMarkup, renderToStaticNodeStream, Stream
|
|
18
|
+
}
|
|
24
19
|
|
|
25
20
|
export default <ITestShape extends ITTestShape>(
|
|
26
21
|
testImplementations: ITestImplementation<
|
|
@@ -39,18 +34,6 @@ export default <ITestShape extends ITTestShape>(
|
|
|
39
34
|
>,
|
|
40
35
|
testInput: IInput
|
|
41
36
|
) => {
|
|
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
|
-
|
|
54
37
|
return Testeranto<
|
|
55
38
|
ITestShape,
|
|
56
39
|
IInput,
|
|
@@ -65,41 +48,32 @@ export default <ITestShape extends ITTestShape>(
|
|
|
65
48
|
testSpecifications,
|
|
66
49
|
testImplementations,
|
|
67
50
|
{
|
|
68
|
-
beforeAll: async (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
): Promise<ISubject> => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
},
|
|
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
|
+
// },
|
|
81
63
|
beforeEach: async (
|
|
82
|
-
|
|
64
|
+
reactComponent,
|
|
83
65
|
ndx,
|
|
84
66
|
testRsource,
|
|
85
67
|
artificer
|
|
86
68
|
): Promise<IStore> => {
|
|
87
69
|
return new Promise((resolve, rej) => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
resolve(
|
|
91
|
-
{
|
|
92
|
-
htmlElement,
|
|
93
|
-
reactElement,
|
|
94
|
-
}
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
}, []);
|
|
98
|
-
ReactDom.createRoot(htmlElement).render(reactElement);
|
|
70
|
+
// Ignore these type errors
|
|
71
|
+
resolve(createElement(testInput));
|
|
99
72
|
});
|
|
100
73
|
},
|
|
101
|
-
andWhen: function (s: IStore, actioner): Promise<ISelection> {
|
|
102
|
-
return actioner()(s);
|
|
74
|
+
andWhen: async function (s: IStore, actioner): Promise<ISelection> {
|
|
75
|
+
// return actioner()(s);
|
|
76
|
+
return s
|
|
103
77
|
},
|
|
104
78
|
butThen: async function (s: IStore): Promise<ISelection> {
|
|
105
79
|
return s;
|
|
@@ -117,3 +91,60 @@ export default <ITestShape extends ITTestShape>(
|
|
|
117
91
|
},
|
|
118
92
|
)
|
|
119
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
|
+
// };
|