testeranto 0.47.10 → 0.47.11

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.
Files changed (38) hide show
  1. package/package.json +6 -1
  2. package/src/subPackages/react/component.ts +20 -0
  3. package/src/subPackages/react/node.ts +99 -0
  4. package/src/subPackages/react/web.ts +99 -0
  5. package/src/subPackages/react-test-render/component.ts +0 -0
  6. package/src/subPackages/react-test-render/node.ts +52 -0
  7. package/src/subPackages/react-test-render/web.ts +52 -0
  8. package/dist/common/Features.js +0 -85
  9. package/dist/common/Node.js +0 -82
  10. package/dist/common/NodeWriter.js +0 -56
  11. package/dist/common/Project.js +0 -648
  12. package/dist/common/Types.js +0 -2
  13. package/dist/common/Web.js +0 -70
  14. package/dist/common/core.js +0 -392
  15. package/dist/common/electron.js +0 -40
  16. package/dist/common/preload.js +0 -8
  17. package/dist/common/tsconfig.common.tsbuildinfo +0 -1
  18. package/dist/module/Features.js +0 -74
  19. package/dist/module/Node.js +0 -77
  20. package/dist/module/NodeWriter.js +0 -50
  21. package/dist/module/Project.js +0 -618
  22. package/dist/module/Report.js +0 -186
  23. package/dist/module/Types.js +0 -1
  24. package/dist/module/Web.js +0 -65
  25. package/dist/module/core.js +0 -383
  26. package/dist/module/electron.js +0 -35
  27. package/dist/module/preload.js +0 -6
  28. package/dist/module/tsconfig.module.tsbuildinfo +0 -1
  29. package/dist/types/Features.d.ts +0 -68
  30. package/dist/types/Node.d.ts +0 -12
  31. package/dist/types/NodeWriter.d.ts +0 -2
  32. package/dist/types/Project.d.ts +0 -32
  33. package/dist/types/Types.d.ts +0 -17
  34. package/dist/types/Web.d.ts +0 -12
  35. package/dist/types/core.d.ts +0 -219
  36. package/dist/types/electron.d.ts +0 -1
  37. package/dist/types/preload.d.ts +0 -1
  38. package/dist/types/tsconfig.types.tsbuildinfo +0 -1
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "testeranto",
3
3
  "description": "teeny tiny tightly-typed typescript tests",
4
- "version": "0.47.10",
4
+ "version": "0.47.11",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.mts",
7
7
  "module": "dist/module/index.js",
8
8
  "exports": {
9
+ "./src/subPackages/": {
10
+ "import": "./src/subPackages/",
11
+ "require": "./src/subPackages/"
12
+ },
9
13
  "./src/Types": {
10
14
  "import": "./dist/module/Types.js",
11
15
  "require": "./dist/common/Types.js"
@@ -102,6 +106,7 @@
102
106
  "puppeteer": "18.1.0",
103
107
  "react-bootstrap": "^2.7.0",
104
108
  "react-sigma": "^1.2.35",
109
+ "react-test-renderer": "^18.2.0",
105
110
  "ws": "^8.16.0"
106
111
  }
107
112
  }
@@ -0,0 +1,20 @@
1
+ import React, { CElement } from "react";
2
+
3
+ export type Input = typeof React.Component;
4
+ export type InitialState = unknown;
5
+ export type WhenShape = any;
6
+ export type ThenShape = any;
7
+ export type Selection = {
8
+ htmlElement: HTMLElement,
9
+ reactElement: CElement<any, any>,
10
+ };
11
+
12
+ export type Store = {
13
+ htmlElement: HTMLElement,
14
+ reactElement: CElement<any, any>,
15
+ };
16
+
17
+ export type Subject = {
18
+ htmlElement: HTMLElement
19
+ };
20
+
@@ -0,0 +1,99 @@
1
+ import React, {
2
+ CElement,
3
+ } from "react";
4
+ import ReactDom from "react-dom/client";
5
+
6
+ import { ITTestShape, ITestImplementation, ITestSpecification } from "../../core";
7
+ import Testeranto from "../../Node";
8
+
9
+ import { InitialState, WhenShape, ThenShape, Subject, Store, Input, Selection } from "./component";
10
+
11
+ export default <ITestShape extends ITTestShape>(
12
+ testImplementations: ITestImplementation<
13
+ InitialState,
14
+ Selection,
15
+ WhenShape,
16
+ ThenShape,
17
+ ITestShape
18
+ >,
19
+ testSpecifications: ITestSpecification<ITestShape>,
20
+ testInput: Input
21
+ ) => {
22
+ class TesterantoComponent extends testInput {
23
+ done: (t: TesterantoComponent) => void;
24
+ constructor(props) {
25
+ super(props);
26
+ this.done = props.done;
27
+ }
28
+ componentDidMount() {
29
+ super.componentDidMount && super.componentDidMount();
30
+ return this.done(this);
31
+ }
32
+ }
33
+
34
+ return Testeranto<
35
+ ITestShape,
36
+ Input,
37
+ Subject,
38
+ Store,
39
+ Selection,
40
+ ThenShape,
41
+ WhenShape,
42
+ InitialState
43
+ >(
44
+ testInput,
45
+ testSpecifications,
46
+ testImplementations,
47
+ {
48
+ beforeAll: async (
49
+ prototype,
50
+ artificer
51
+ ): Promise<Subject> => {
52
+ return await new Promise((resolve, rej) => {
53
+ document.addEventListener("DOMContentLoaded", function () {
54
+ const elem = document.getElementById("root");
55
+ if (elem) {
56
+ resolve({ htmlElement: elem });
57
+ }
58
+ });
59
+ })
60
+ },
61
+ beforeEach: async (
62
+ { htmlElement },
63
+ ndx,
64
+ testRsource,
65
+ artificer
66
+ ): Promise<Store> => {
67
+ return new Promise((resolve, rej) => {
68
+ const reactElement = React.createElement(TesterantoComponent, {
69
+ done: (reactElement) => {
70
+ resolve(
71
+ {
72
+ htmlElement,
73
+ reactElement,
74
+ }
75
+ );
76
+ }
77
+ }, []);
78
+ ReactDom.createRoot(htmlElement).render(reactElement);
79
+ });
80
+ },
81
+ andWhen: function (s: Store, actioner): Promise<Selection> {
82
+ return actioner()(s);
83
+ },
84
+ butThen: async function (s: Store): Promise<Selection> {
85
+ return s;
86
+ },
87
+ afterEach: async function (
88
+ store: Store,
89
+ ndx,
90
+ artificer
91
+ ) {
92
+ return {};
93
+ },
94
+ afterAll: (store: Store, artificer) => {
95
+ return;
96
+ },
97
+ },
98
+ )
99
+ };
@@ -0,0 +1,99 @@
1
+ import React, {
2
+ CElement,
3
+ } from "react";
4
+ import ReactDom from "react-dom/client";
5
+
6
+ import { ITTestShape, ITestImplementation, ITestSpecification } from "../../core";
7
+ import Testeranto from "../../Web";
8
+
9
+ import { InitialState, WhenShape, ThenShape, Subject, Store, Input, Selection } from "./component";
10
+
11
+ export default <ITestShape extends ITTestShape>(
12
+ testImplementations: ITestImplementation<
13
+ InitialState,
14
+ Selection,
15
+ WhenShape,
16
+ ThenShape,
17
+ ITestShape
18
+ >,
19
+ testSpecifications: ITestSpecification<ITestShape>,
20
+ testInput: Input
21
+ ) => {
22
+ class TesterantoComponent extends testInput {
23
+ done: (t: TesterantoComponent) => void;
24
+ constructor(props) {
25
+ super(props);
26
+ this.done = props.done;
27
+ }
28
+ componentDidMount() {
29
+ super.componentDidMount && super.componentDidMount();
30
+ return this.done(this);
31
+ }
32
+ }
33
+
34
+ return Testeranto<
35
+ ITestShape,
36
+ Input,
37
+ Subject,
38
+ Store,
39
+ Selection,
40
+ ThenShape,
41
+ WhenShape,
42
+ InitialState
43
+ >(
44
+ testInput,
45
+ testSpecifications,
46
+ testImplementations,
47
+ {
48
+ beforeAll: async (
49
+ prototype,
50
+ artificer
51
+ ): Promise<Subject> => {
52
+ return await new Promise((resolve, rej) => {
53
+ document.addEventListener("DOMContentLoaded", function () {
54
+ const elem = document.getElementById("root");
55
+ if (elem) {
56
+ resolve({ htmlElement: elem });
57
+ }
58
+ });
59
+ })
60
+ },
61
+ beforeEach: async (
62
+ { htmlElement },
63
+ ndx,
64
+ testRsource,
65
+ artificer
66
+ ): Promise<Store> => {
67
+ return new Promise((resolve, rej) => {
68
+ const reactElement = React.createElement(TesterantoComponent, {
69
+ done: (reactElement) => {
70
+ resolve(
71
+ {
72
+ htmlElement,
73
+ reactElement,
74
+ }
75
+ );
76
+ }
77
+ }, []);
78
+ ReactDom.createRoot(htmlElement).render(reactElement);
79
+ });
80
+ },
81
+ andWhen: function (s: Store, actioner): Promise<Selection> {
82
+ return actioner()(s);
83
+ },
84
+ butThen: async function (s: Store): Promise<Selection> {
85
+ return s;
86
+ },
87
+ afterEach: async function (
88
+ store: Store,
89
+ ndx,
90
+ artificer
91
+ ) {
92
+ return {};
93
+ },
94
+ afterAll: (store: Store, artificer) => {
95
+ return;
96
+ },
97
+ },
98
+ )
99
+ };
File without changes
@@ -0,0 +1,52 @@
1
+ import React from "react";
2
+ import renderer, { act } from "react-test-renderer";
3
+
4
+ import Testeranto from "../../Web";
5
+ import { ITestImplementation, ITestSpecification, ITTestShape } from "../../core";
6
+
7
+ import { WhenShape, ThenShape, Input } from "./component";
8
+
9
+ export const ReactTestRendererTesteranto = <
10
+ ITestShape extends ITTestShape,
11
+ PropShape,
12
+ StateShape
13
+ >(
14
+ testImplementations: ITestImplementation<
15
+ PropShape,
16
+ renderer.ReactTestRenderer,
17
+ WhenShape,
18
+ ThenShape,
19
+ ITestShape
20
+ >,
21
+ testSpecifications: ITestSpecification<ITestShape>,
22
+ testInput: Input,
23
+ ) =>
24
+ Testeranto<
25
+ ITestShape,
26
+ Input,
27
+ any,
28
+ any,
29
+ any,
30
+ any,
31
+ any,
32
+ any
33
+ >(
34
+ testInput,
35
+ testSpecifications,
36
+ testImplementations,
37
+ {
38
+ beforeEach: function (CComponent, props): Promise<renderer.ReactTestRenderer> {
39
+ let component;
40
+ act(() => {
41
+ component = renderer.create(
42
+ React.createElement(CComponent, props, [])
43
+ );
44
+ });
45
+ return component;
46
+ },
47
+ andWhen: async function (renderer: renderer.ReactTestRenderer, actioner: any): Promise<renderer.ReactTestRenderer> {
48
+ await act(() => actioner()(renderer));
49
+ return renderer
50
+ }
51
+ }
52
+ )
@@ -0,0 +1,52 @@
1
+ import React from "react";
2
+ import renderer, { act } from "react-test-renderer";
3
+
4
+ import Testeranto from "../../Web";
5
+ import { ITTestShape, ITestImplementation, ITestSpecification } from "../../core";
6
+
7
+ import { WhenShape, ThenShape, Input } from "./component";
8
+
9
+ export const ReactTestRendererTesteranto = <
10
+ ITestShape extends ITTestShape,
11
+ PropShape,
12
+ StateShape
13
+ >(
14
+ testImplementations: ITestImplementation<
15
+ PropShape,
16
+ renderer.ReactTestRenderer,
17
+ WhenShape,
18
+ ThenShape,
19
+ ITestShape
20
+ >,
21
+ testSpecifications: ITestSpecification<ITestShape>,
22
+ testInput: Input,
23
+ ) =>
24
+ Testeranto<
25
+ ITestShape,
26
+ Input,
27
+ any,
28
+ any,
29
+ any,
30
+ any,
31
+ any,
32
+ any
33
+ >(
34
+ testInput,
35
+ testSpecifications,
36
+ testImplementations,
37
+ {
38
+ beforeEach: function (CComponent, props): Promise<renderer.ReactTestRenderer> {
39
+ let component;
40
+ act(() => {
41
+ component = renderer.create(
42
+ React.createElement(CComponent, props, [])
43
+ );
44
+ });
45
+ return component;
46
+ },
47
+ andWhen: async function (renderer: renderer.ReactTestRenderer, actioner: any): Promise<renderer.ReactTestRenderer> {
48
+ await act(() => actioner()(renderer));
49
+ return renderer
50
+ }
51
+ }
52
+ )
@@ -1,85 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DirectedGraph = exports.TesterantoFeatures = exports.TesterantoGraphDirectedAcyclic = exports.TesterantoGraphDirected = exports.TesterantoGraphUndirected = exports.BaseFeature = void 0;
7
- const graphology_1 = __importDefault(require("graphology"));
8
- /* @ts-ignore:next-line */
9
- const { DirectedGraph, UndirectedGraph } = graphology_1.default;
10
- exports.DirectedGraph = DirectedGraph;
11
- class TesterantoGraph {
12
- constructor(name) {
13
- this.name = name;
14
- }
15
- }
16
- class BaseFeature {
17
- constructor(name) {
18
- this.name = name;
19
- }
20
- }
21
- exports.BaseFeature = BaseFeature;
22
- class TesterantoGraphUndirected {
23
- constructor(name) {
24
- this.name = name;
25
- this.graph = new UndirectedGraph();
26
- }
27
- connect(a, b, relation) {
28
- this.graph.mergeEdge(a, b, { type: relation });
29
- }
30
- }
31
- exports.TesterantoGraphUndirected = TesterantoGraphUndirected;
32
- class TesterantoGraphDirected {
33
- constructor(name) {
34
- this.name = name;
35
- this.graph = new DirectedGraph();
36
- }
37
- connect(to, from, relation) {
38
- this.graph.mergeEdge(to, from, { type: relation });
39
- }
40
- }
41
- exports.TesterantoGraphDirected = TesterantoGraphDirected;
42
- class TesterantoGraphDirectedAcyclic {
43
- constructor(name) {
44
- this.name = name;
45
- this.graph = new DirectedGraph();
46
- }
47
- connect(to, from, relation) {
48
- this.graph.mergeEdge(to, from, { type: relation });
49
- }
50
- }
51
- exports.TesterantoGraphDirectedAcyclic = TesterantoGraphDirectedAcyclic;
52
- class TesterantoFeatures {
53
- constructor(features, graphs) {
54
- this.features = features;
55
- this.graphs = graphs;
56
- }
57
- networks() {
58
- return [
59
- ...this.graphs.undirected.values(),
60
- ...this.graphs.directed.values(),
61
- ...this.graphs.dags.values(),
62
- ];
63
- }
64
- toObj() {
65
- return {
66
- features: Object.entries(this.features).map(([name, feature]) => {
67
- return Object.assign(Object.assign({}, feature), { inNetworks: this.networks()
68
- .filter((network) => {
69
- return network.graph.hasNode(feature.name);
70
- })
71
- .map((network) => {
72
- return {
73
- network: network.name,
74
- neighbors: network.graph.neighbors(feature.name),
75
- };
76
- }) });
77
- }),
78
- networks: this.networks().map((network) => {
79
- return Object.assign({}, network);
80
- }),
81
- };
82
- }
83
- }
84
- exports.TesterantoFeatures = TesterantoFeatures;
85
- exports.default = {};
@@ -1,82 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const core_js_1 = require("./core.js");
7
- const core_js_2 = __importDefault(require("./core.js"));
8
- const NodeWriter_js_1 = require("./NodeWriter.js");
9
- const receiveTestResourceConfig = async (t, testresource) => {
10
- const { failed, artifacts, logPromise } = await t.receiveTestResourceConfig(testresource);
11
- /* @ts-ignore:next-line */
12
- process.send({
13
- type: "testeranto:adios",
14
- data: {
15
- failed,
16
- testResourceConfiguration: t.test.testResourceConfiguration,
17
- results: t.toObj(),
18
- },
19
- }, async (err) => {
20
- if (!err) {
21
- Promise.all([...artifacts, logPromise]).then(async () => {
22
- process.exit(await failed ? 1 : 0);
23
- });
24
- }
25
- else {
26
- console.error(err);
27
- process.exit(1);
28
- }
29
- });
30
- };
31
- exports.default = async (input, testSpecification, testImplementation, testInterface, testResourceRequirement = core_js_1.defaultTestResourceRequirement) => {
32
- const mrt = new core_js_2.default(input, testSpecification, testImplementation, testInterface, testResourceRequirement, testInterface.assertioner || (async (t) => t), testInterface.beforeEach || async function (subject, initialValues, testResource) {
33
- return subject;
34
- }, testInterface.afterEach || (async (s) => s), testInterface.afterAll || ((store) => undefined), testInterface.butThen || (async (a) => a), testInterface.andWhen, testInterface.actionHandler ||
35
- function (b) {
36
- return b;
37
- }, NodeWriter_js_1.NodeWriter);
38
- const tl2 = mrt;
39
- const t = tl2.testJobs[0];
40
- const testResourceArg = process.argv[2] || `{}`;
41
- try {
42
- const partialTestResource = JSON.parse(testResourceArg);
43
- if (testResourceRequirement.ports == 0) {
44
- receiveTestResourceConfig(t, partialTestResource);
45
- }
46
- else {
47
- console.log("test configuration is incomplete", partialTestResource);
48
- console.log("requesting test resources via IPC ...", testResourceRequirement);
49
- /* @ts-ignore:next-line */
50
- process.send({
51
- type: "testeranto:hola",
52
- data: {
53
- requirement: Object.assign(Object.assign({}, testResourceRequirement), { name: partialTestResource.name })
54
- },
55
- });
56
- console.log("awaiting test resources via IPC...");
57
- process.on("message", async function (packet) {
58
- console.log("message: ", packet);
59
- const resourcesFromPm2 = packet.data.testResourceConfiguration;
60
- const secondTestResource = Object.assign(Object.assign({ fs: "." }, JSON.parse(JSON.stringify(partialTestResource))), JSON.parse(JSON.stringify(resourcesFromPm2)));
61
- console.log("secondTestResource", secondTestResource);
62
- receiveTestResourceConfig(t, secondTestResource);
63
- });
64
- }
65
- }
66
- catch (e) {
67
- console.error(e);
68
- process.exit(-1);
69
- }
70
- };
71
- // else {
72
- // console.log("Pass run-time test resources by STDIN", process.stdin);
73
- // process.stdin.on("data", async (data) => {
74
- // console.log("data: ", data);
75
- // const resourcesFromStdin = JSON.parse(data.toString());
76
- // const secondTestResource = {
77
- // ...JSON.parse(JSON.stringify(resourcesFromStdin)),
78
- // ...JSON.parse(JSON.stringify(partialTestResource)),
79
- // } as ITTestResourceConfiguration;
80
- // await t.receiveTestResourceConfig(secondTestResource);
81
- // });
82
- // }
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.NodeWriter = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
- const fPaths = [];
10
- exports.NodeWriter = {
11
- createWriteStream: (filepath) => {
12
- return fs_1.default.createWriteStream(filepath);
13
- },
14
- writeFileSync: (fp, contents) => {
15
- fs_1.default.writeFileSync(fp, contents);
16
- },
17
- mkdirSync: async (fp) => {
18
- await fs_1.default.mkdirSync(fp, { recursive: true });
19
- },
20
- testArtiFactoryfileWriter: (tLog, callback) => (fPath, value) => {
21
- callback(new Promise((res, rej) => {
22
- tLog("testArtiFactory =>", fPath);
23
- const cleanPath = path_1.default.resolve(fPath);
24
- fPaths.push(cleanPath.replace(process.cwd(), ``));
25
- const targetDir = cleanPath.split("/").slice(0, -1).join("/");
26
- fs_1.default.mkdir(targetDir, { recursive: true }, async (error) => {
27
- if (error) {
28
- console.error(`❗️testArtiFactory failed`, targetDir, error);
29
- }
30
- fs_1.default.writeFileSync(path_1.default.resolve(targetDir.split("/").slice(0, -1).join("/"), "manifest"), fPaths.join(`\n`), {
31
- encoding: "utf-8",
32
- });
33
- if (Buffer.isBuffer(value)) {
34
- fs_1.default.writeFileSync(fPath, value, "binary");
35
- res();
36
- }
37
- else if (`string` === typeof value) {
38
- fs_1.default.writeFileSync(fPath, value.toString(), {
39
- encoding: "utf-8",
40
- });
41
- res();
42
- }
43
- else {
44
- /* @ts-ignore:next-line */
45
- const pipeStream = value;
46
- const myFile = fs_1.default.createWriteStream(fPath);
47
- pipeStream.pipe(myFile);
48
- pipeStream.on("close", () => {
49
- myFile.close();
50
- res();
51
- });
52
- }
53
- });
54
- }));
55
- }
56
- };