@khanacademy/wonder-blocks-testing 11.0.1 → 12.0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @khanacademy/wonder-blocks-testing
2
2
 
3
+ ## 12.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 02a1b298: Make sure we don't package tsconfig and tsbuildinfo files
8
+ - Updated dependencies [02a1b298]
9
+ - @khanacademy/wonder-blocks-core@7.0.1
10
+ - @khanacademy/wonder-blocks-data@13.0.12
11
+ - @khanacademy/wonder-blocks-testing-core@1.0.2
12
+
13
+ ## 12.0.0
14
+
15
+ ### Major Changes
16
+
17
+ - 490b5fa4: Rename ssr adapter to renderState
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [07f7f407]
22
+ - @khanacademy/wonder-blocks-core@7.0.0
23
+ - @khanacademy/wonder-blocks-data@13.0.11
24
+
3
25
  ## 11.0.1
4
26
 
5
27
  ### Patch Changes
package/dist/es/index.js CHANGED
@@ -83,11 +83,11 @@ const DefaultAdapters = {
83
83
  data: adapter$1,
84
84
  portal: harnessAdapters.DefaultAdapters.portal,
85
85
  router: harnessAdapters.DefaultAdapters.router,
86
- ssr: adapter
86
+ renderState: adapter
87
87
  };
88
88
  const DefaultConfigs = _extends({}, harnessAdapters.DefaultConfigs, {
89
89
  data: defaultConfig$1,
90
- ssr: defaultConfig
90
+ renderState: defaultConfig
91
91
  });
92
92
 
93
93
  var index = /*#__PURE__*/Object.freeze({
@@ -33,7 +33,7 @@ export declare const DefaultAdapters: {
33
33
  location: import("history").LocationDescriptor<unknown>;
34
34
  path?: string | undefined;
35
35
  }>>;
36
- readonly ssr: import("@khanacademy/wonder-blocks-testing-core").TestHarnessAdapter<true>;
36
+ readonly renderState: import("@khanacademy/wonder-blocks-testing-core").TestHarnessAdapter<true>;
37
37
  };
38
38
  /**
39
39
  * The default configurations to use with the `DefaultAdapters`.
@@ -0,0 +1,16 @@
1
+ import type { TestHarnessAdapter } from "@khanacademy/wonder-blocks-testing-core";
2
+ type Config = true;
3
+ export declare const defaultConfig: Config | null;
4
+ /**
5
+ * Test harness adapter for supporting render state-based hooks and components.
6
+ *
7
+ * Some components and hooks utilize the render state context to manage what
8
+ * they render and when. In order for this to work, a `RenderStateRoot`
9
+ * component must be present to track the current render state.
10
+ *
11
+ * This adapter wraps the children in a `RenderStateRoot` component to enable
12
+ * the render state context. This adapter should be used when testing components
13
+ * that rely on the render state.
14
+ */
15
+ export declare const adapter: TestHarnessAdapter<Config>;
16
+ export {};
package/dist/index.js CHANGED
@@ -109,11 +109,11 @@ const DefaultAdapters = {
109
109
  data: adapter$1,
110
110
  portal: wonderBlocksTestingCore.harnessAdapters.DefaultAdapters.portal,
111
111
  router: wonderBlocksTestingCore.harnessAdapters.DefaultAdapters.router,
112
- ssr: adapter
112
+ renderState: adapter
113
113
  };
114
114
  const DefaultConfigs = _extends__default["default"]({}, wonderBlocksTestingCore.harnessAdapters.DefaultConfigs, {
115
115
  data: defaultConfig$1,
116
- ssr: defaultConfig
116
+ renderState: defaultConfig
117
117
  });
118
118
 
119
119
  var index = /*#__PURE__*/Object.freeze({
package/package.json CHANGED
@@ -1,36 +1,36 @@
1
1
  {
2
- "name": "@khanacademy/wonder-blocks-testing",
3
- "version": "11.0.1",
4
- "design": "v1",
5
- "publishConfig": {
6
- "access": "public"
7
- },
8
- "description": "",
9
- "main": "dist/index.js",
10
- "module": "dist/es/index.js",
11
- "types": "dist/index.d.ts",
12
- "scripts": {
13
- "test": "echo \"Error: no test specified\" && exit 1"
14
- },
15
- "dependencies": {
16
- "@babel/runtime": "^7.18.6",
17
- "@khanacademy/wonder-blocks-core": "^6.4.3",
18
- "@khanacademy/wonder-blocks-data": "^13.0.10",
19
- "@khanacademy/wonder-blocks-testing-core": "^1.0.1"
20
- },
21
- "peerDependencies": {
22
- "@khanacademy/wonder-stuff-core": "^1.2.2",
23
- "@storybook/addon-actions": "^7.0.0",
24
- "aphrodite": "^1.2.5",
25
- "node-fetch": "^2.6.7",
26
- "react": "16.14.0",
27
- "react-dom": "16.14.0",
28
- "react-router-dom": "5.3.0"
29
- },
30
- "devDependencies": {
31
- "@khanacademy/wb-dev-build-settings": "^1.0.1",
32
- "@khanacademy/wonder-stuff-testing": "^3.0.1"
33
- },
34
- "author": "",
35
- "license": "MIT"
36
- }
2
+ "name": "@khanacademy/wonder-blocks-testing",
3
+ "version": "12.0.1",
4
+ "design": "v1",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "description": "",
9
+ "main": "dist/index.js",
10
+ "module": "dist/es/index.js",
11
+ "types": "dist/index.d.ts",
12
+ "scripts": {
13
+ "test": "echo \"Error: no test specified\" && exit 1"
14
+ },
15
+ "dependencies": {
16
+ "@babel/runtime": "^7.18.6",
17
+ "@khanacademy/wonder-blocks-core": "^7.0.1",
18
+ "@khanacademy/wonder-blocks-data": "^13.0.12",
19
+ "@khanacademy/wonder-blocks-testing-core": "^1.0.2"
20
+ },
21
+ "peerDependencies": {
22
+ "@khanacademy/wonder-stuff-core": "^1.2.2",
23
+ "@storybook/addon-actions": "^7.0.0",
24
+ "aphrodite": "^1.2.5",
25
+ "node-fetch": "^2.6.7",
26
+ "react": "16.14.0",
27
+ "react-dom": "16.14.0",
28
+ "react-router-dom": "5.3.0"
29
+ },
30
+ "devDependencies": {
31
+ "@khanacademy/wb-dev-build-settings": "^1.0.1",
32
+ "@khanacademy/wonder-stuff-testing": "^3.0.1"
33
+ },
34
+ "author": "",
35
+ "license": "MIT"
36
+ }
@@ -1,12 +0,0 @@
1
- import type { TestHarnessAdapter } from "@khanacademy/wonder-blocks-testing-core";
2
- type Config = true;
3
- export declare const defaultConfig: Config | null;
4
- /**
5
- * Test harness adapter for supporting portals.
6
- *
7
- * Some components rely on rendering with a React Portal. This adapter ensures
8
- * that the DOM contains a mounting point for the portal with the expected
9
- * identifier.
10
- */
11
- export declare const adapter: TestHarnessAdapter<Config>;
12
- export {};
@@ -1,234 +0,0 @@
1
- import {gqlRequestMatchesMock} from "../gql-request-matches-mock";
2
-
3
- describe("#gqlRequestMatchesMock", () => {
4
- it("should return false if operation types don't match", () => {
5
- // Arrange
6
- const mock = {
7
- operation: {
8
- id: "foo",
9
- type: "query",
10
- },
11
- } as const;
12
- const operation = {
13
- id: "foo",
14
- type: "mutation",
15
- } as const;
16
-
17
- // Act
18
- const result = gqlRequestMatchesMock(mock, operation, null, {});
19
-
20
- // Assert
21
- expect(result).toBe(false);
22
- });
23
-
24
- it("should return false if operation ids don't match", () => {
25
- // Arrange
26
- const mock = {
27
- operation: {
28
- id: "foo",
29
- type: "query",
30
- },
31
- } as const;
32
-
33
- // Act
34
- const result = gqlRequestMatchesMock(
35
- mock,
36
- {
37
- id: "bar",
38
- type: "query",
39
- },
40
- null,
41
- {},
42
- );
43
-
44
- // Assert
45
- expect(result).toBe(false);
46
- });
47
-
48
- it.each([{foo: "bar"}, {foo: "baz", anExtra: "property"}, null])(
49
- "should return false if variables don't match",
50
- (variables: any) => {
51
- // Arrange
52
- const mock = {
53
- operation: {
54
- id: "foo",
55
- type: "query",
56
- },
57
- variables: {
58
- foo: "baz",
59
- },
60
- } as const;
61
- const operation = {
62
- id: "foo",
63
- type: "query",
64
- } as const;
65
-
66
- // Act
67
- const result = gqlRequestMatchesMock(
68
- mock,
69
- operation,
70
- variables,
71
- {},
72
- );
73
-
74
- // Assert
75
- expect(result).toBe(false);
76
- },
77
- );
78
-
79
- it.each([{a: "context"}, null])(
80
- "should return false if contexts don't match",
81
- (context: any) => {
82
- // Arrange
83
- const mock = {
84
- operation: {
85
- id: "foo",
86
- type: "query",
87
- },
88
- variables: {
89
- foo: "bar",
90
- },
91
- context: {
92
- mock: "context",
93
- },
94
- } as const;
95
- const operation = {
96
- id: "foo",
97
- type: "query",
98
- } as const;
99
- const variables = {
100
- foo: "bar",
101
- } as const;
102
-
103
- // Act
104
- const result = gqlRequestMatchesMock(
105
- mock,
106
- operation,
107
- variables,
108
- context,
109
- );
110
-
111
- // Assert
112
- expect(result).toBe(false);
113
- },
114
- );
115
-
116
- it("should return true if operation matches and mock does not include context nor variables, regardless of comparison operation variables and context", () => {
117
- // Arrange
118
- const mock = {
119
- operation: {
120
- id: "foo",
121
- type: "query",
122
- },
123
- } as const;
124
-
125
- // Act
126
- const result = gqlRequestMatchesMock(
127
- mock,
128
- {
129
- id: "foo",
130
- type: "query",
131
- },
132
- {a: "variable"},
133
- {my: "context"},
134
- );
135
-
136
- // Assert
137
- expect(result).toBe(true);
138
- });
139
-
140
- it("should return true if operation and variables match and there is no mock context", () => {
141
- // Arrange
142
- const mock = {
143
- operation: {
144
- id: "foo",
145
- type: "query",
146
- },
147
- variables: {
148
- foo: "bar",
149
- },
150
- } as const;
151
-
152
- // Act
153
- const result = gqlRequestMatchesMock(
154
- mock,
155
- {
156
- id: "foo",
157
- type: "query",
158
- },
159
- {
160
- foo: "bar",
161
- },
162
- {my: "context"},
163
- );
164
-
165
- // Assert
166
- expect(result).toBe(true);
167
- });
168
-
169
- it("should return true if operation and context match and there are no mock variables", () => {
170
- // Arrange
171
- const mock = {
172
- operation: {
173
- id: "foo",
174
- type: "query",
175
- },
176
- context: {
177
- foo: "bar",
178
- },
179
- } as const;
180
-
181
- // Act
182
- const result = gqlRequestMatchesMock(
183
- mock,
184
- {
185
- id: "foo",
186
- type: "query",
187
- },
188
- {a: "variable"},
189
- {
190
- foo: "bar",
191
- },
192
- );
193
-
194
- // Assert
195
- expect(result).toBe(true);
196
- });
197
-
198
- it("should return true if everything matches", () => {
199
- // Arrange
200
- const mock = {
201
- operation: {
202
- id: "foo",
203
- type: "query",
204
- },
205
- variables: {
206
- foo: "bar",
207
- },
208
- context: {
209
- foo: "bar",
210
- },
211
- } as const;
212
- const operation = {
213
- id: "foo",
214
- type: "query",
215
- } as const;
216
- const variables = {
217
- foo: "bar",
218
- } as const;
219
- const context = {
220
- foo: "bar",
221
- } as const;
222
-
223
- // Act
224
- const result = gqlRequestMatchesMock(
225
- mock,
226
- operation,
227
- {...variables},
228
- {...context},
229
- );
230
-
231
- // Assert
232
- expect(result).toBe(true);
233
- });
234
- });