testeranto 0.49.0 → 0.49.2

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.
@@ -6,25 +6,13 @@ import React, {
6
6
  import ReactDom from "react-dom/client";
7
7
 
8
8
  import { ITTestShape, ITestImplementation, ITestSpecification } from "../../../core";
9
-
10
- type Input = [string, (string) => string, any];
11
- type InitialState = unknown;
12
- type IWhenShape = any;
13
- type IThenShape = any;
14
- type ISelection = IStore;
15
-
16
- type Prototype = () => JSX.Element;
17
- type IStore = {
18
- root: HTMLElement,
19
- react: HTMLElement,
20
- };
21
- type ISubject = {
22
- root: HTMLElement
23
- };
9
+ import {
10
+ IInput, ISelection, IStore, ISubject, IThenShape, IWhenShape, IState
11
+ } from ".";
24
12
 
25
13
  export default <ITestShape extends ITTestShape>(
26
14
  testImplementations: ITestImplementation<
27
- InitialState,
15
+ IState,
28
16
  ISelection,
29
17
  IWhenShape,
30
18
  IThenShape,
@@ -37,59 +25,55 @@ export default <ITestShape extends ITTestShape>(
37
25
  ISelection,
38
26
  IThenShape
39
27
  >,
40
- testInput: Prototype
28
+ testInput: IInput
41
29
  ) => {
42
30
  document.addEventListener("DOMContentLoaded", function () {
43
- const elem = document.getElementById("root");
44
- if (elem) {
45
- const TesterantoComponent = function (props) {
31
+ console.log("DOMContentLoaded");
32
+ const rootElement = document.getElementById("root");
33
+ if (rootElement) {
34
+ const TesterantoComponent = function (innerProps) {
46
35
  const myContainer = useRef(null);
47
-
48
36
  useEffect(() => {
49
37
  console.log(
50
- "This only happens ONCE. It happens AFTER the initial render."
38
+ "useEffect called"
51
39
  );
52
- // eslint-disable-next-line react/prop-types
53
- props.done(myContainer.current);
40
+ innerProps.done(myContainer.current);
54
41
  }, []);
55
42
 
56
- return React.createElement('div', { ref: myContainer }, testInput()); //testInput();
43
+ return React.createElement(
44
+ 'div',
45
+ { ref: myContainer },
46
+ testInput()
47
+ );
57
48
  };
58
49
 
59
50
  Testeranto<
60
51
  ITestShape,
61
- Prototype,
52
+ IInput,
62
53
  ISubject,
63
54
  IStore,
64
55
  ISelection,
65
56
  IThenShape,
66
57
  IWhenShape,
67
- InitialState
58
+ IState
68
59
  >(
69
60
  testInput,
70
61
  testSpecifications,
71
62
  testImplementations,
72
63
  {
73
- beforeAll: async (
74
- prototype,
75
- artificer
76
- ): Promise<ISubject> => {
77
- return new Promise((resolve, rej) => {
78
- resolve({ root: elem });
79
- })
80
- },
81
64
  beforeEach: async (
82
- { root },
65
+ subject,
83
66
  ndx,
84
67
  testRsource,
85
68
  artificer
86
69
  ): Promise<IStore> => {
87
70
  return new Promise((resolve, rej) => {
88
- ReactDom.createRoot(root).
71
+ ReactDom.createRoot(rootElement).
89
72
  render(
73
+ // ignore this type error
90
74
  React.createElement(
91
75
  TesterantoComponent, {
92
- done: (react) => resolve({ root, react })
76
+ done: (reactElement: any) => resolve(reactElement)
93
77
  }, []));
94
78
  });
95
79
  },
@@ -107,7 +91,6 @@ export default <ITestShape extends ITTestShape>(
107
91
  return {};
108
92
  },
109
93
  afterAll: (store: IStore, artificer) => {
110
- // store.page.browser().close();
111
94
  return;
112
95
  },
113
96
  },