testeranto 0.48.9 → 0.48.14

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.
@@ -1,10 +1,11 @@
1
+ import Testeranto from "../../../Web";
2
+
1
3
  import React, {
2
4
  useEffect, useRef,
3
5
  } from "react";
4
6
  import ReactDom from "react-dom/client";
5
7
 
6
8
  import { ITTestShape, ITestImplementation, ITestSpecification } from "../../../core";
7
- import Testeranto from "../../../../src/Web";
8
9
 
9
10
  type Input = [string, (string) => string, any];
10
11
  type InitialState = unknown;
@@ -38,80 +39,79 @@ export default <ITestShape extends ITTestShape>(
38
39
  >,
39
40
  testInput: Prototype
40
41
  ) => {
41
- const TesterantoComponent = function (props) {
42
- const myContainer = useRef(null);
42
+ document.addEventListener("DOMContentLoaded", function () {
43
+ const elem = document.getElementById("root");
44
+ if (elem) {
45
+ const TesterantoComponent = function (props) {
46
+ const myContainer = useRef(null);
43
47
 
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
- }, []);
48
+ useEffect(() => {
49
+ console.log(
50
+ "This only happens ONCE. It happens AFTER the initial render."
51
+ );
52
+ // eslint-disable-next-line react/prop-types
53
+ props.done(myContainer.current);
54
+ }, []);
51
55
 
52
- return React.createElement('div', { ref: myContainer }, testInput()); //testInput();
53
- };
56
+ return React.createElement('div', { ref: myContainer }, testInput()); //testInput();
57
+ };
54
58
 
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) {
59
+ Testeranto<
60
+ ITestShape,
61
+ Prototype,
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 new Promise((resolve, rej) => {
78
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
- )
79
+ })
80
+ },
81
+ beforeEach: async (
82
+ { root },
83
+ ndx,
84
+ testRsource,
85
+ artificer
86
+ ): Promise<IStore> => {
87
+ return new Promise((resolve, rej) => {
88
+ ReactDom.createRoot(root).
89
+ render(
90
+ React.createElement(
91
+ TesterantoComponent, {
92
+ done: (react) => resolve({ root, react })
93
+ }, []));
94
+ });
95
+ },
96
+ andWhen: function (s: IStore, actioner): Promise<ISelection> {
97
+ return actioner()(s);
98
+ },
99
+ butThen: async function (s: IStore): Promise<ISelection> {
100
+ return s;
101
+ },
102
+ afterEach: async function (
103
+ store: IStore,
104
+ ndx,
105
+ artificer
106
+ ) {
107
+ return {};
108
+ },
109
+ afterAll: (store: IStore, artificer) => {
110
+ // store.page.browser().close();
111
+ return;
112
+ },
113
+ },
114
+ )
115
+ }
116
+ });
117
117
  };