testeranto 0.49.0 → 0.49.1

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