@leaflink/dom-testing-utils 4.2.3 → 5.0.0-alpha.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.
- package/README.md +87 -65
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/mocks/IntersectionObserverMock.d.ts +24 -0
- package/dist/mocks/IntersectionObserverMock.js +72 -0
- package/dist/mocks/IntersectionObserverMock.js.map +1 -0
- package/dist/mocks/LocationMock.d.ts +6 -0
- package/dist/mocks/LocationMock.js +70 -0
- package/dist/mocks/LocationMock.js.map +1 -0
- package/dist/mocks/MutationObserverMock.d.ts +7 -0
- package/dist/mocks/MutationObserverMock.js +15 -0
- package/dist/mocks/MutationObserverMock.js.map +1 -0
- package/dist/mocks/ResizeObserverMock.d.ts +7 -0
- package/dist/mocks/ResizeObserverMock.js +13 -0
- package/dist/mocks/ResizeObserverMock.js.map +1 -0
- package/dist/mocks/matchMediaMock.d.ts +5 -0
- package/dist/mocks/matchMediaMock.js +15 -0
- package/dist/mocks/matchMediaMock.js.map +1 -0
- package/dist/setup-env.d.ts +1 -1
- package/dist/setup-env.js +32 -63
- package/dist/setup-env.js.map +1 -1
- package/dist/setup-env.spec.js +2 -2
- package/dist/setup-env.spec.js.map +1 -1
- package/dist/utils/__tests__/createFixtureGenerator.spec.js +19 -0
- package/dist/utils/__tests__/createFixtureGenerator.spec.js.map +1 -1
- package/dist/utils/cleanupDialogs.d.ts +10 -0
- package/dist/utils/cleanupDialogs.js +15 -0
- package/dist/utils/cleanupDialogs.js.map +1 -0
- package/dist/utils/cleanupDropdowns.d.ts +1 -1
- package/dist/utils/cleanupDropdowns.js +2 -2
- package/dist/utils/cleanupDropdowns.js.map +1 -1
- package/dist/utils/cleanupMenus.d.ts +10 -0
- package/dist/utils/cleanupMenus.js +15 -0
- package/dist/utils/cleanupMenus.js.map +1 -0
- package/dist/utils/cleanupModals.d.ts +1 -1
- package/dist/utils/cleanupModals.js +3 -3
- package/dist/utils/cleanupModals.js.map +1 -1
- package/dist/utils/cleanupNoty.js +1 -1
- package/dist/utils/cleanupNoty.js.map +1 -1
- package/dist/utils/cleanupToasts.d.ts +1 -1
- package/dist/utils/cleanupToasts.js +3 -3
- package/dist/utils/cleanupToasts.js.map +1 -1
- package/dist/utils/createFixtureGenerator.d.ts +2 -2
- package/dist/utils/createFixtureGenerator.js +1 -1
- package/dist/utils/createFixtureGenerator.js.map +1 -1
- package/package.json +27 -14
package/README.md
CHANGED
|
@@ -11,30 +11,46 @@
|
|
|
11
11
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
12
12
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
13
13
|
|
|
14
|
-
- [
|
|
15
|
-
- [
|
|
16
|
-
- [
|
|
17
|
-
- [
|
|
18
|
-
- [
|
|
19
|
-
|
|
20
|
-
- [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
- [@leaflink/dom-testing-utils](#leaflinkdom-testing-utils)
|
|
15
|
+
- [Installation](#installation)
|
|
16
|
+
- [Releases](#releases)
|
|
17
|
+
- [Usage](#usage)
|
|
18
|
+
- [Setup file](#setup-file)
|
|
19
|
+
- [Global setup](#global-setup)
|
|
20
|
+
- [Utilities](#utilities)
|
|
21
|
+
- [`cleanupNoty`](#cleanupnoty)
|
|
22
|
+
- [`waitForLoading`](#waitforloading)
|
|
23
|
+
- [`cleanupDropdowns`](#cleanupdropdowns)
|
|
24
|
+
- [`assertAndDismissNoty`](#assertanddismissnoty)
|
|
25
|
+
- [`getByDescriptionTerm`](#getbydescriptionterm)
|
|
26
|
+
- [`getAllByDescriptionTerm`](#getallbydescriptionterm)
|
|
27
|
+
- [`getSelectedOption`](#getselectedoption)
|
|
28
|
+
- [`getSelectedOptions`](#getselectedoptions)
|
|
29
|
+
- [`createFixtureGenerator`](#createfixturegenerator)
|
|
30
|
+
- [Mocking API Endpoints](#mocking-api-endpoints)
|
|
29
31
|
|
|
30
32
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
31
33
|
|
|
32
34
|
## Installation
|
|
33
35
|
|
|
36
|
+
**Requirements:** Node.js >= 24
|
|
37
|
+
|
|
34
38
|
```sh
|
|
35
|
-
|
|
39
|
+
pnpm add -D @leaflink/dom-testing-utils
|
|
36
40
|
```
|
|
37
41
|
|
|
42
|
+
## Releases
|
|
43
|
+
|
|
44
|
+
Releases are fully automated using [semantic-release](https://github.com/semantic-release/semantic-release). When changes are pushed to a release branch (`main`, `alpha`, `beta`, `canary`, `next`, `next-major`, or `[0-9]+.x`), the CI workflow:
|
|
45
|
+
|
|
46
|
+
1. Builds the package with `pnpm build`
|
|
47
|
+
2. Analyzes commits to determine the next version (using [Conventional Commits](https://www.conventionalcommits.org/))
|
|
48
|
+
3. Publishes to npm and creates a GitHub release with changelog
|
|
49
|
+
|
|
50
|
+
**Commit types that trigger releases:** `feat`, `fix`, `perf`, and `revert`. Other types (e.g. `docs`, `chore`) appear in changelogs but do not bump the version on their own.
|
|
51
|
+
|
|
52
|
+
For detailed commit conventions and manual release instructions, see [CONTRIBUTING.md](.github/CONTRIBUTING.md#semantic-release).
|
|
53
|
+
|
|
38
54
|
## Usage
|
|
39
55
|
|
|
40
56
|
In your test files you can import utility functions.
|
|
@@ -71,7 +87,7 @@ setupFiles: ['tests/setup-env.js'],
|
|
|
71
87
|
setupFilesAfterEnv: ['<rootDir>/tests/setup-env.js']
|
|
72
88
|
```
|
|
73
89
|
|
|
74
|
-
This will be run once before
|
|
90
|
+
This will be run once before _each_ test file. See <https://vitest.dev/config/#setupfiles>.
|
|
75
91
|
|
|
76
92
|
### Global setup
|
|
77
93
|
|
|
@@ -85,7 +101,7 @@ globalSetup: ['node_modules/@leaflink/dom-testing-utils/dist/global-setup.js'],
|
|
|
85
101
|
globalSetup: ['<rootDir>/node_modules/@leaflink/dom-testing-utils/dist/global-setup.js']
|
|
86
102
|
```
|
|
87
103
|
|
|
88
|
-
This will run once
|
|
104
|
+
This will run once _before everything_. See <https://vitest.dev/config/#globalsetup>.
|
|
89
105
|
|
|
90
106
|
## Utilities
|
|
91
107
|
|
|
@@ -101,11 +117,11 @@ Helper method to remove all noty alerts from the DOM.
|
|
|
101
117
|
|
|
102
118
|
Utility that waits for all loading elements to be removed from the DOM. The `data-test` argument defaults to `ll-loading` **or** `loading-spinner` if `testId` is not specified.
|
|
103
119
|
|
|
104
|
-
| **Parameters** | **Type** | **Default**
|
|
105
|
-
|
|
|
106
|
-
| testId
|
|
107
|
-
| timeout
|
|
108
|
-
| failIfNull
|
|
120
|
+
| **Parameters** | **Type** | **Default** | **Summary** |
|
|
121
|
+
| -------------- | -------- | --------------------------------- | --------------------------------------------------- |
|
|
122
|
+
| testId | `string` | `ll-loading` && `loading-spinner` | The data test ID to target. |
|
|
123
|
+
| timeout | number | 2000 | How long to wait for loading elements to be removed |
|
|
124
|
+
| failIfNull | boolean | false | Throws an error if no loading elements are found |
|
|
109
125
|
|
|
110
126
|
**Returns**: `Promise<void>`
|
|
111
127
|
|
|
@@ -123,11 +139,11 @@ Helper method to remove all floating Stash Dropdown elements from the DOM.
|
|
|
123
139
|
|
|
124
140
|
### `assertAndDismissNoty`
|
|
125
141
|
|
|
126
|
-
Helper to assert and manually dismiss a notification.
|
|
142
|
+
Helper to assert and manually dismiss a notification. This is useful in scenarios where cleanupNoty() does not work as expected, such as when validating error messages in test suites.
|
|
127
143
|
|
|
128
|
-
| **Parameters** | **Type** | **Default** | **Summary**
|
|
129
|
-
|
|
|
130
|
-
| text
|
|
144
|
+
| **Parameters** | **Type** | **Default** | **Summary** |
|
|
145
|
+
| -------------- | -------- | ----------- | --------------------------- |
|
|
146
|
+
| text | `string` | _Required_ | Expected notification text. |
|
|
131
147
|
|
|
132
148
|
**Returns**: `void`
|
|
133
149
|
|
|
@@ -135,46 +151,43 @@ Helper to assert and manually dismiss a notification. This is useful in scenari
|
|
|
135
151
|
|
|
136
152
|
Finds the first HTML element with the role "definition" (DD) that matches the specified text for the description term.
|
|
137
153
|
|
|
138
|
-
| **Parameters** | **Type**
|
|
139
|
-
|
|
|
140
|
-
| text
|
|
154
|
+
| **Parameters** | **Type** | **Default** | **Summary** |
|
|
155
|
+
| -------------- | ------------------ | ----------- | --------------------------------------- |
|
|
156
|
+
| text | `string \| RegExp` | _Required_ | Expected description term text or regex |
|
|
141
157
|
|
|
142
158
|
**Returns**: `HTMLElement | undefined` - The first matching description detail element or undefined if no match is found.
|
|
143
159
|
|
|
144
|
-
|
|
145
160
|
### `getAllByDescriptionTerm`
|
|
146
161
|
|
|
147
162
|
Queries and returns an array of HTML elements with the role "definition" (DD) that matches the specified text of a description term.
|
|
148
163
|
|
|
149
|
-
| **Parameters** | **Type**
|
|
150
|
-
|
|
|
151
|
-
| textMatch
|
|
164
|
+
| **Parameters** | **Type** | **Default** | **Summary** |
|
|
165
|
+
| -------------- | ------------------ | ----------- | --------------------------------------------------------------------------------------- |
|
|
166
|
+
| textMatch | `string \| RegExp` | _Required_ | The text to match within the HTML elements. It can be a string or a regular expression. |
|
|
152
167
|
|
|
153
168
|
**Returns**: `HTMLElement[]` - An array of HTML description detail elements that match the given text.
|
|
154
169
|
|
|
155
|
-
|
|
156
170
|
### `getSelectedOption`
|
|
157
171
|
|
|
158
172
|
Finds the first selected HTML element with the role "definition" (LI) "listitem" inside the specified select element.
|
|
159
173
|
|
|
160
|
-
| **Parameters** | **Type**
|
|
161
|
-
|
|
|
162
|
-
| element
|
|
163
|
-
| selectedClass
|
|
164
|
-
| options
|
|
174
|
+
| **Parameters** | **Type** | **Default** | **Summary** |
|
|
175
|
+
| -------------- | ----------------- | ------------- | ---------------------------------------------------------- |
|
|
176
|
+
| element | HTMLSelectElement | _Required_ | Stash Select element to be checked. |
|
|
177
|
+
| selectedClass | string | 'is-selected' | Selected class added on selected items |
|
|
178
|
+
| options | ByRoleOptions | null | `getAllByRole()` options values using `ByRoleOptions` type |
|
|
165
179
|
|
|
166
180
|
**Returns**: `HTMLElement | undefined` - The first selected HTML listitem element or undefined if no match is found.
|
|
167
181
|
|
|
168
|
-
|
|
169
182
|
### `getSelectedOptions`
|
|
170
183
|
|
|
171
184
|
Finds all the selected HTML elements with the role "definition" (LI) "listitem" inside the specified select element.
|
|
172
185
|
|
|
173
|
-
| **Parameters** | **Type**
|
|
174
|
-
|
|
|
175
|
-
| element
|
|
176
|
-
| selectedClass
|
|
177
|
-
| options
|
|
186
|
+
| **Parameters** | **Type** | **Default** | **Summary** |
|
|
187
|
+
| -------------- | ----------------- | ------------- | ---------------------------------------------------------- |
|
|
188
|
+
| element | HTMLSelectElement | _Required_ | Stash Select element to be checked. |
|
|
189
|
+
| selectedClass | string | 'is-selected' | Selected class added on selected items |
|
|
190
|
+
| options | ByRoleOptions | null | `getAllByRole()` options values using `ByRoleOptions` type |
|
|
178
191
|
|
|
179
192
|
**Returns**: `HTMLElement[]` - An array of selected HTML listitem elements.
|
|
180
193
|
|
|
@@ -182,9 +195,9 @@ Finds all the selected HTML elements with the role "definition" (LI) "listitem"
|
|
|
182
195
|
|
|
183
196
|
Higher order function that takes a method whose responsibility is to create a **single** data fixture object and returns a new generator function that allows you to create 1 or more of those fixtures. Fixture generator function that's returned supports passing optional `num` and `overrides` params.
|
|
184
197
|
|
|
185
|
-
| **Parameters** | **Type**
|
|
186
|
-
|
|
|
187
|
-
| `fixtureFn`
|
|
198
|
+
| **Parameters** | **Type** | **Default** | **Summary** |
|
|
199
|
+
| -------------- | ---------- | ----------- | ------------------------------------------------------- |
|
|
200
|
+
| `fixtureFn` | `function` | _Required_ | Method that generates and returns a single data object. |
|
|
188
201
|
|
|
189
202
|
**Returns**
|
|
190
203
|
|
|
@@ -206,25 +219,30 @@ When calling the returned function, you'll get an array OR object of fixture dat
|
|
|
206
219
|
Quick example:
|
|
207
220
|
|
|
208
221
|
```ts
|
|
209
|
-
const generateInvoice = (overrides) => ({
|
|
222
|
+
const generateInvoice = (overrides) => ({
|
|
223
|
+
id: uuid(),
|
|
224
|
+
balance: 15799,
|
|
225
|
+
classification: 'Adult Use',
|
|
226
|
+
...overrides,
|
|
227
|
+
});
|
|
210
228
|
const generateInvoices = createFixtureGenerator(generateInvoice);
|
|
211
229
|
|
|
212
|
-
generateInvoices()
|
|
230
|
+
generateInvoices();
|
|
213
231
|
// => Single invoice object
|
|
214
232
|
|
|
215
|
-
generateInvoices(1)
|
|
233
|
+
generateInvoices(1);
|
|
216
234
|
// => Single invoice object
|
|
217
235
|
|
|
218
|
-
generateInvoices(1, { foo: 'bar' })
|
|
236
|
+
generateInvoices(1, { foo: 'bar' });
|
|
219
237
|
// => Single invoice object, override `foo` to equal `'bar'`
|
|
220
238
|
|
|
221
|
-
generateInvoices({ foo: 'bar' })
|
|
239
|
+
generateInvoices({ foo: 'bar' });
|
|
222
240
|
// => Single invoice object, override `foo` to equal `'bar'`
|
|
223
241
|
|
|
224
|
-
generateInvoices(10)
|
|
242
|
+
generateInvoices(10);
|
|
225
243
|
// => Array of 10 invoice objects
|
|
226
244
|
|
|
227
|
-
generateInvoices(10, { foo: 'bar' })
|
|
245
|
+
generateInvoices(10, { foo: 'bar' });
|
|
228
246
|
// => Array of 10 invoice objects, override `foo` to equal `'bar'` in each
|
|
229
247
|
```
|
|
230
248
|
|
|
@@ -249,7 +267,7 @@ export default createFixtureGenerator(generateProduct);
|
|
|
249
267
|
import generateProducts from '@/tests/fixtures/products';
|
|
250
268
|
|
|
251
269
|
// ...
|
|
252
|
-
const mockProducts = generateProducts(10, { cases: 25 })
|
|
270
|
+
const mockProducts = generateProducts(10, { cases: 25 });
|
|
253
271
|
// ...
|
|
254
272
|
```
|
|
255
273
|
|
|
@@ -270,20 +288,24 @@ const {
|
|
|
270
288
|
```
|
|
271
289
|
|
|
272
290
|
There are two flavors of mocking utility functions:
|
|
291
|
+
|
|
273
292
|
1. mock{VERB}Data - mocks response with a singular data object
|
|
274
293
|
2. mock{VERB}Endpoint - mocks a response endpoint with a function like msw's [Response Resolver](https://mswjs.io/docs/getting-started/mocks/rest-api#response-resolver)
|
|
275
294
|
|
|
276
295
|
To mock an endpoint with simple return data
|
|
296
|
+
|
|
277
297
|
```ts
|
|
278
|
-
|
|
298
|
+
mockGetData('/relative-url', myMockObj);
|
|
279
299
|
```
|
|
300
|
+
|
|
280
301
|
or you can customize the response
|
|
302
|
+
|
|
281
303
|
```ts
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
304
|
+
mockGetEndpoint('/relative-url', (req, res, ctx) => {
|
|
305
|
+
if (someConditional()) {
|
|
306
|
+
HttpResponse.json({ foo: 'bar' });
|
|
307
|
+
} else {
|
|
308
|
+
HttpResponse.json({ foo: 'baz' });
|
|
309
|
+
}
|
|
310
|
+
});
|
|
289
311
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export { default as assertAndDismissNoty } from './utils/assertAndDismissNoty.js';
|
|
2
|
+
export { default as cleanupDialogs, cleanupDialogsMountNode } from './utils/cleanupDialogs.js';
|
|
2
3
|
export { default as cleanupDropdowns } from './utils/cleanupDropdowns.js';
|
|
3
|
-
export { default as
|
|
4
|
+
export { default as cleanupMenus, cleanupMenusMountNode } from './utils/cleanupMenus.js';
|
|
5
|
+
export { default as cleanupModals, cleanupModalsMountNode } from './utils/cleanupModals.js';
|
|
4
6
|
export { default as cleanupNoty } from './utils/cleanupNoty.js';
|
|
5
|
-
export { default as cleanupToasts } from './utils/cleanupToasts.js';
|
|
7
|
+
export { default as cleanupToasts, cleanupToastsMountNode } from './utils/cleanupToasts.js';
|
|
6
8
|
export { default as createFixtureGenerator } from './utils/createFixtureGenerator.js';
|
|
7
9
|
export { default as getAllByDescriptionTerm } from './utils/getAllByDescriptionTerm.js';
|
|
8
10
|
export { default as getByDescriptionTerm } from './utils/getByDescriptionTerm.js';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export { default as assertAndDismissNoty } from './utils/assertAndDismissNoty.js';
|
|
2
|
+
export { default as cleanupDialogs, cleanupDialogsMountNode } from './utils/cleanupDialogs.js';
|
|
2
3
|
export { default as cleanupDropdowns } from './utils/cleanupDropdowns.js';
|
|
3
|
-
export { default as
|
|
4
|
+
export { default as cleanupMenus, cleanupMenusMountNode } from './utils/cleanupMenus.js';
|
|
5
|
+
export { default as cleanupModals, cleanupModalsMountNode } from './utils/cleanupModals.js';
|
|
4
6
|
export { default as cleanupNoty } from './utils/cleanupNoty.js';
|
|
5
|
-
export { default as cleanupToasts } from './utils/cleanupToasts.js';
|
|
7
|
+
export { default as cleanupToasts, cleanupToastsMountNode } from './utils/cleanupToasts.js';
|
|
6
8
|
export { default as createFixtureGenerator } from './utils/createFixtureGenerator.js';
|
|
7
9
|
export { default as getAllByDescriptionTerm } from './utils/getAllByDescriptionTerm.js';
|
|
8
10
|
export { default as getByDescriptionTerm } from './utils/getByDescriptionTerm.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACzF,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AACtF,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AACxF,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAc,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface IntersectionObserverMockInterface extends IntersectionObserver {
|
|
2
|
+
target: Element | null;
|
|
3
|
+
scrollCallback: IntersectionObserverCallback;
|
|
4
|
+
onScroll(e: Event): void;
|
|
5
|
+
}
|
|
6
|
+
export declare class IntersectionObserverMock implements IntersectionObserverMockInterface {
|
|
7
|
+
root: IntersectionObserver['root'];
|
|
8
|
+
rootMargin: IntersectionObserver['rootMargin'];
|
|
9
|
+
thresholds: IntersectionObserver['thresholds'];
|
|
10
|
+
target: Element | null;
|
|
11
|
+
disconnect: IntersectionObserver['disconnect'];
|
|
12
|
+
observe: IntersectionObserver['observe'];
|
|
13
|
+
takeRecords: IntersectionObserver['takeRecords'];
|
|
14
|
+
unobserve: IntersectionObserver['unobserve'];
|
|
15
|
+
scrollCallback: IntersectionObserverCallback;
|
|
16
|
+
onScroll(e: Event): void;
|
|
17
|
+
constructor(callback: IntersectionObserverCallback);
|
|
18
|
+
}
|
|
19
|
+
export declare function mockIntersectionObserver(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Dispatches the custom scroll event used by the viewable directive. Used
|
|
22
|
+
* in tandem with the IntersectionObserverMock to perform the scroll.
|
|
23
|
+
*/
|
|
24
|
+
export declare function dispatchCustomScroll(eventDetails?: Partial<IntersectionObserverEntry>): void;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export class IntersectionObserverMock {
|
|
2
|
+
root = null;
|
|
3
|
+
rootMargin = '0px 0px 0px 0px';
|
|
4
|
+
thresholds = [];
|
|
5
|
+
target = null;
|
|
6
|
+
disconnect = IntersectionObserverMock.prototype.disconnect.bind(this);
|
|
7
|
+
observe = IntersectionObserverMock.prototype.observe.bind(this);
|
|
8
|
+
takeRecords = IntersectionObserverMock.prototype.takeRecords.bind(this);
|
|
9
|
+
unobserve = IntersectionObserverMock.prototype.unobserve.bind(this);
|
|
10
|
+
scrollCallback;
|
|
11
|
+
onScroll(e) {
|
|
12
|
+
if (!(e instanceof CustomEvent)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const { detail } = e;
|
|
16
|
+
this.scrollCallback([
|
|
17
|
+
{
|
|
18
|
+
intersectionRatio: detail.intersectionRatio,
|
|
19
|
+
isIntersecting: detail.isIntersecting,
|
|
20
|
+
},
|
|
21
|
+
], new IntersectionObserverMock(this.scrollCallback));
|
|
22
|
+
}
|
|
23
|
+
constructor(callback) {
|
|
24
|
+
this.scrollCallback = callback;
|
|
25
|
+
window.addEventListener('scroll', this.onScroll.bind(this));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function mockIntersectionObserver() {
|
|
29
|
+
IntersectionObserverMock.prototype.disconnect = vi.fn(function () { });
|
|
30
|
+
IntersectionObserverMock.prototype.observe = vi.fn(function (element) {
|
|
31
|
+
this.target = element;
|
|
32
|
+
});
|
|
33
|
+
IntersectionObserverMock.prototype.takeRecords = vi.fn(function () {
|
|
34
|
+
return [];
|
|
35
|
+
});
|
|
36
|
+
IntersectionObserverMock.prototype.unobserve = vi.fn(function () {
|
|
37
|
+
this.target = null;
|
|
38
|
+
window.removeEventListener('scroll', this.onScroll);
|
|
39
|
+
});
|
|
40
|
+
vi.stubGlobal('IntersectionObserver', IntersectionObserverMock);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Dispatches the custom scroll event used by the viewable directive. Used
|
|
44
|
+
* in tandem with the IntersectionObserverMock to perform the scroll.
|
|
45
|
+
*/
|
|
46
|
+
export function dispatchCustomScroll(eventDetails) {
|
|
47
|
+
const MOCK_DOM_RECT = {
|
|
48
|
+
bottom: 0,
|
|
49
|
+
height: 0,
|
|
50
|
+
left: 0,
|
|
51
|
+
right: 0,
|
|
52
|
+
top: 0,
|
|
53
|
+
width: 0,
|
|
54
|
+
x: 0,
|
|
55
|
+
y: 0,
|
|
56
|
+
toJSON: () => null,
|
|
57
|
+
};
|
|
58
|
+
const detail = {
|
|
59
|
+
boundingClientRect: MOCK_DOM_RECT,
|
|
60
|
+
intersectionRatio: 1,
|
|
61
|
+
intersectionRect: MOCK_DOM_RECT,
|
|
62
|
+
isIntersecting: true,
|
|
63
|
+
rootBounds: null,
|
|
64
|
+
target: document.body,
|
|
65
|
+
time: 0,
|
|
66
|
+
...eventDetails,
|
|
67
|
+
};
|
|
68
|
+
window.dispatchEvent(new CustomEvent('scroll', {
|
|
69
|
+
detail,
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=IntersectionObserverMock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntersectionObserverMock.js","sourceRoot":"src/","sources":["mocks/IntersectionObserverMock.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,wBAAwB;IACnC,IAAI,GAAiC,IAAI,CAAC;IAC1C,UAAU,GAAuC,iBAAiB,CAAC;IACnE,UAAU,GAAuC,EAAE,CAAC;IACpD,MAAM,GAAmB,IAAI,CAAC;IAE9B,UAAU,GAAuC,wBAAwB,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE1G,OAAO,GAAoC,wBAAwB,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEjG,WAAW,GAAwC,wBAAwB,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE7G,SAAS,GAAsC,wBAAwB,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEvG,cAAc,CAA+B;IAE7C,QAAQ,CAAC,CAAQ;QACf,IAAI,CAAC,CAAC,CAAC,YAAY,WAAW,CAAC,EAAE,CAAC;YAChC,OAAO;QACT,CAAC;QAED,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAErB,IAAI,CAAC,cAAc,CACjB;YACE;gBACE,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;gBAC3C,cAAc,EAAE,MAAM,CAAC,cAAc;aACT;SAC/B,EACD,IAAI,wBAAwB,CAAC,IAAI,CAAC,cAAc,CAAC,CAClD,CAAC;IACJ,CAAC;IAED,YAAY,QAAsC;QAChD,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC;QAE/B,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC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G,YAAY;KAChB,CAAC;IAEF,MAAM,CAAC,aAAa,CAClB,IAAI,WAAW,CAAC,QAAQ,EAAE;QACxB,MAAM;KACP,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type RawLocation = Pick<Location, 'hash' | 'host' | 'hostname' | 'href' | 'origin' | 'pathname' | 'search'>;
|
|
2
|
+
/**
|
|
3
|
+
* Mocks the global location object with the provided location object. Defaults to window.location.
|
|
4
|
+
*/
|
|
5
|
+
export declare function mockLocation(location?: Partial<RawLocation>): void;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const originalLocation = window.location;
|
|
2
|
+
/**
|
|
3
|
+
* Mocks the global location object with the provided location object. Defaults to window.location.
|
|
4
|
+
*/
|
|
5
|
+
export function mockLocation(location) {
|
|
6
|
+
const locationMock = Object.defineProperties({}, {
|
|
7
|
+
...Object.getOwnPropertyDescriptors(originalLocation),
|
|
8
|
+
assign: {
|
|
9
|
+
configurable: true,
|
|
10
|
+
value: vi.fn(),
|
|
11
|
+
},
|
|
12
|
+
reload: {
|
|
13
|
+
configurable: true,
|
|
14
|
+
value: vi.fn(),
|
|
15
|
+
},
|
|
16
|
+
push: {
|
|
17
|
+
configurable: true,
|
|
18
|
+
value: vi.fn(),
|
|
19
|
+
},
|
|
20
|
+
replace: {
|
|
21
|
+
configurable: true,
|
|
22
|
+
value: vi.fn(),
|
|
23
|
+
},
|
|
24
|
+
href: {
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: location?.href || originalLocation.href,
|
|
28
|
+
},
|
|
29
|
+
host: {
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true,
|
|
32
|
+
value: location?.host || originalLocation.host,
|
|
33
|
+
},
|
|
34
|
+
hostname: {
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true,
|
|
37
|
+
value: location?.hostname || originalLocation.hostname,
|
|
38
|
+
},
|
|
39
|
+
...(location?.pathname !== undefined && {
|
|
40
|
+
pathname: {
|
|
41
|
+
configurable: true,
|
|
42
|
+
writable: true,
|
|
43
|
+
value: location.pathname,
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
...(location?.search !== undefined && {
|
|
47
|
+
search: {
|
|
48
|
+
configurable: true,
|
|
49
|
+
writable: true,
|
|
50
|
+
value: location.search,
|
|
51
|
+
},
|
|
52
|
+
}),
|
|
53
|
+
...(location?.hash !== undefined && {
|
|
54
|
+
hash: {
|
|
55
|
+
configurable: true,
|
|
56
|
+
writable: true,
|
|
57
|
+
value: location.hash,
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
...(location?.origin !== undefined && {
|
|
61
|
+
origin: {
|
|
62
|
+
configurable: true,
|
|
63
|
+
writable: true,
|
|
64
|
+
value: location.origin,
|
|
65
|
+
},
|
|
66
|
+
}),
|
|
67
|
+
});
|
|
68
|
+
vi.stubGlobal('location', locationMock);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=LocationMock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocationMock.js","sourceRoot":"src/","sources":["mocks/LocationMock.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG,MAAM,CAAC,QAAQ,CAAC;AAIzC;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,QAA+B;IAC1D,MAAM,YAAY,GAAG,MAAM,CAAC,gBAAgB,CAAC,EAAc,EAAE;QAC3D,GAAG,MAAM,CAAC,yBAAyB,CAAC,gBAAgB,CAAC;QACrD,MAAM,EAAE;YACN,YAAY,EAAE,IAAI;YAClB,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;SACf;QACD,MAAM,EAAE;YACN,YAAY,EAAE,IAAI;YAClB,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;SACf;QACD,IAAI,EAAE;YACJ,YAAY,EAAE,IAAI;YAClB,KAAK,EAAE,EAAE,CAAC,EAAE,EAA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IAEH,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare class MutationObserverMock implements MutationObserver {
|
|
2
|
+
takeRecords: MutationObserver['takeRecords'];
|
|
3
|
+
observe: MutationObserver['observe'];
|
|
4
|
+
disconnect: MutationObserver['disconnect'];
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
7
|
+
export declare function mockMutationObserver(): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class MutationObserverMock {
|
|
2
|
+
takeRecords = MutationObserverMock.prototype.takeRecords.bind(this);
|
|
3
|
+
observe = MutationObserverMock.prototype.observe.bind(this);
|
|
4
|
+
disconnect = MutationObserverMock.prototype.disconnect.bind(this);
|
|
5
|
+
constructor() { }
|
|
6
|
+
}
|
|
7
|
+
export function mockMutationObserver() {
|
|
8
|
+
MutationObserverMock.prototype.takeRecords = vi.fn(function () {
|
|
9
|
+
return [];
|
|
10
|
+
});
|
|
11
|
+
MutationObserverMock.prototype.observe = vi.fn(function () { });
|
|
12
|
+
MutationObserverMock.prototype.disconnect = vi.fn(function () { });
|
|
13
|
+
vi.stubGlobal('MutationObserver', MutationObserverMock);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=MutationObserverMock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MutationObserverMock.js","sourceRoot":"src/","sources":["mocks/MutationObserverMock.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,oBAAoB;IAC/B,WAAW,GAAoC,oBAAoB,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrG,OAAO,GAAgC,oBAAoB,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzF,UAAU,GAAmC,oBAAoB,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElG,gBAAe,CAAC;CACjB;AAED,MAAM,UAAU,oBAAoB;IAClC,oBAAoB,CAAC,SAAS,CAAC,WAAW,GAAG,EAAE,CAAC,EAAE,CAAC;QACjD,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;IACH,oBAAoB,CAAC,SAAS,CAAC,OAAO,GAAG,EAAE,CAAC,EAAE,CAAC,cAAuC,CAAC,CAAC,CAAC;IACzF,oBAAoB,CAAC,SAAS,CAAC,UAAU,GAAG,EAAE,CAAC,EAAE,CAAC,cAAuC,CAAC,CAAC,CAAC;IAE5F,EAAE,CAAC,UAAU,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class ResizeObserverMock {
|
|
2
|
+
disconnect = ResizeObserverMock.prototype.disconnect.bind(this);
|
|
3
|
+
observe = ResizeObserverMock.prototype.observe.bind(this);
|
|
4
|
+
unobserve = ResizeObserverMock.prototype.unobserve.bind(this);
|
|
5
|
+
constructor() { }
|
|
6
|
+
}
|
|
7
|
+
export function mockResizeObserver() {
|
|
8
|
+
ResizeObserverMock.prototype.disconnect = vi.fn(function () { });
|
|
9
|
+
ResizeObserverMock.prototype.observe = vi.fn(function () { });
|
|
10
|
+
ResizeObserverMock.prototype.unobserve = vi.fn(function () { });
|
|
11
|
+
vi.stubGlobal('ResizeObserver', ResizeObserverMock);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=ResizeObserverMock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResizeObserverMock.js","sourceRoot":"src/","sources":["mocks/ResizeObserverMock.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,kBAAkB;IAC7B,UAAU,GAAiC,kBAAkB,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9F,OAAO,GAA8B,kBAAkB,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrF,SAAS,GAAgC,kBAAkB,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE3F,gBAAe,CAAC;CACjB;AAED,MAAM,UAAU,kBAAkB;IAChC,kBAAkB,CAAC,SAAS,CAAC,UAAU,GAAG,EAAE,CAAC,EAAE,CAAC,cAAqC,CAAC,CAAC,CAAC;IACxF,kBAAkB,CAAC,SAAS,CAAC,OAAO,GAAG,EAAE,CAAC,EAAE,CAAC,cAAqC,CAAC,CAAC,CAAC;IACrF,kBAAkB,CAAC,SAAS,CAAC,SAAS,GAAG,EAAE,CAAC,EAAE,CAAC,cAAqC,CAAC,CAAC,CAAC;IAEvF,EAAE,CAAC,UAAU,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function mockMatchMedia({ matches, mediaQueryMatches }) {
|
|
2
|
+
vi.stubGlobal('matchMedia', vi.fn(function (query) {
|
|
3
|
+
return {
|
|
4
|
+
matches: mediaQueryMatches && mediaQueryMatches[query] !== undefined ? mediaQueryMatches[query] : matches,
|
|
5
|
+
media: query,
|
|
6
|
+
onchange: null,
|
|
7
|
+
addListener: vi.fn(), // deprecated
|
|
8
|
+
removeListener: vi.fn(), // deprecated
|
|
9
|
+
addEventListener: vi.fn(),
|
|
10
|
+
removeEventListener: vi.fn(),
|
|
11
|
+
dispatchEvent: vi.fn(),
|
|
12
|
+
};
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=matchMediaMock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchMediaMock.js","sourceRoot":"src/","sources":["mocks/matchMediaMock.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,cAAc,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAsB;IAC/E,EAAE,CAAC,UAAU,CACX,YAAY,EACZ,EAAE,CAAC,EAAE,CAAC,UAAU,KAAa;QAC3B,OAAO;YACL,OAAO,EAAE,iBAAiB,IAAI,iBAAiB,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO;YACzG,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,aAAa;YACnC,cAAc,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,aAAa;YACtC,gBAAgB,EAAE,EAAE,CAAC,EAAE,EAAE;YACzB,mBAAmB,EAAE,EAAE,CAAC,EAAE,EAAE;YAC5B,aAAa,EAAE,EAAE,CAAC,EAAE,EAAE;SACvB,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
package/dist/setup-env.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import '@testing-library/jest-dom';
|
|
1
|
+
import '@testing-library/jest-dom/vitest';
|
package/dist/setup-env.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import '@testing-library/jest-dom';
|
|
1
|
+
import '@testing-library/jest-dom/vitest';
|
|
2
2
|
import { configure as configureTestingLibrary } from '@testing-library/vue';
|
|
3
|
+
// eslint-disable-next-line no-restricted-imports
|
|
3
4
|
import { config, flushPromises } from '@vue/test-utils';
|
|
4
5
|
import { vi } from 'vitest';
|
|
6
|
+
import { mockIntersectionObserver } from './mocks/IntersectionObserverMock.js';
|
|
7
|
+
import { mockLocation } from './mocks/LocationMock.js';
|
|
8
|
+
import { mockMatchMedia } from './mocks/matchMediaMock.js';
|
|
9
|
+
import { mockMutationObserver } from './mocks/MutationObserverMock.js';
|
|
10
|
+
import { mockResizeObserver } from './mocks/ResizeObserverMock.js';
|
|
11
|
+
import cleanupDialogs, { cleanupDialogsMountNode } from './utils/cleanupDialogs.js';
|
|
5
12
|
import cleanupDropdowns from './utils/cleanupDropdowns.js';
|
|
13
|
+
import cleanupMenus, { cleanupMenusMountNode } from './utils/cleanupMenus.js';
|
|
6
14
|
import cleanupModals, { cleanupModalsMountNode } from './utils/cleanupModals.js';
|
|
7
15
|
import cleanupNoty from './utils/cleanupNoty.js';
|
|
8
16
|
import cleanupToasts, { cleanupToastsMountNode } from './utils/cleanupToasts.js';
|
|
@@ -12,7 +20,7 @@ import cleanupToasts, { cleanupToastsMountNode } from './utils/cleanupToasts.js'
|
|
|
12
20
|
// from assistive technology
|
|
13
21
|
const defaultHidden = !process.env.CI;
|
|
14
22
|
configureTestingLibrary({ testIdAttribute: 'data-test', defaultHidden });
|
|
15
|
-
// Mock debounce
|
|
23
|
+
// Mock the debounce function so that we can test it synchronously
|
|
16
24
|
vi.mock('lodash-es/debounce', () => {
|
|
17
25
|
return {
|
|
18
26
|
default: (fn) => {
|
|
@@ -21,77 +29,38 @@ vi.mock('lodash-es/debounce', () => {
|
|
|
21
29
|
},
|
|
22
30
|
};
|
|
23
31
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
value: {
|
|
39
|
-
replace: vi.fn(),
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
vi.stubGlobal('open', vi.fn());
|
|
44
|
-
global.window.ResizeObserver =
|
|
45
|
-
global.window.ResizeObserver ||
|
|
46
|
-
class ResizeObserver {
|
|
47
|
-
observe() { }
|
|
48
|
-
unobserve() { }
|
|
49
|
-
disconnect() { }
|
|
50
|
-
};
|
|
51
|
-
afterAll(() => {
|
|
52
|
-
cleanupModalsMountNode();
|
|
53
|
-
cleanupToastsMountNode();
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
vi.stubGlobal('open', vi.fn());
|
|
34
|
+
mockLocation();
|
|
35
|
+
mockResizeObserver();
|
|
36
|
+
mockIntersectionObserver();
|
|
37
|
+
mockMutationObserver();
|
|
38
|
+
mockMatchMedia({ matches: false });
|
|
39
|
+
global.URL.createObjectURL = vi.fn();
|
|
40
|
+
// Uploading a file does not use axios, so mock the fetch api
|
|
41
|
+
// See src/services/api/files.js->uploadFile for more info
|
|
42
|
+
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({ json: vi.fn().mockResolvedValue({}) }));
|
|
43
|
+
// https://github.com/jsdom/jsdom/issues/1695
|
|
44
|
+
Element.prototype.scrollIntoView = vi.fn();
|
|
45
|
+
config.global.mocks['$t'] = (msg) => msg;
|
|
54
46
|
});
|
|
55
47
|
afterEach(() => {
|
|
56
48
|
cleanupModals();
|
|
57
49
|
cleanupToasts();
|
|
50
|
+
cleanupDialogs();
|
|
51
|
+
cleanupMenus();
|
|
58
52
|
cleanupNoty();
|
|
59
53
|
cleanupDropdowns();
|
|
60
54
|
});
|
|
61
55
|
afterEach(async () => {
|
|
62
|
-
// flush out any pending promises so they will fail the test instead of asynchronously at
|
|
63
|
-
// the wrong time
|
|
64
|
-
// Todo: figure out why this isnt working
|
|
56
|
+
// flush out any pending promises so they will fail the test instead of asynchronously at the wrong time
|
|
65
57
|
await flushPromises();
|
|
66
58
|
});
|
|
67
59
|
afterAll(() => {
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
// remove mount nodes from the DOM
|
|
61
|
+
cleanupModalsMountNode();
|
|
62
|
+
cleanupToastsMountNode();
|
|
63
|
+
cleanupDialogsMountNode();
|
|
64
|
+
cleanupMenusMountNode();
|
|
71
65
|
});
|
|
72
|
-
const IntersectionObserverMock = vi.fn(() => ({
|
|
73
|
-
get root() {
|
|
74
|
-
return;
|
|
75
|
-
},
|
|
76
|
-
disconnect: vi.fn(),
|
|
77
|
-
observe: vi.fn(),
|
|
78
|
-
takeRecords: vi.fn(),
|
|
79
|
-
unobserve: vi.fn(),
|
|
80
|
-
}));
|
|
81
|
-
vi.stubGlobal('IntersectionObserver', IntersectionObserverMock);
|
|
82
|
-
// Uploading a file does not use axios, so mock the fetch api
|
|
83
|
-
// See src/services/api/files.js->uploadFile for more info
|
|
84
|
-
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({ json: vi.fn().mockResolvedValue({}) }));
|
|
85
|
-
// https://github.com/jsdom/jsdom/issues/1695
|
|
86
|
-
Element.prototype.scrollIntoView = vi.fn();
|
|
87
|
-
window.matchMedia = vi.fn((query) => ({
|
|
88
|
-
matches: false,
|
|
89
|
-
media: query,
|
|
90
|
-
onchange: null,
|
|
91
|
-
addListener: vi.fn(),
|
|
92
|
-
removeListener: vi.fn(),
|
|
93
|
-
addEventListener: vi.fn(),
|
|
94
|
-
removeEventListener: vi.fn(),
|
|
95
|
-
dispatchEvent: vi.fn(),
|
|
96
|
-
}));
|
|
97
66
|
//# sourceMappingURL=setup-env.js.map
|
package/dist/setup-env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-env.js","sourceRoot":"src/","sources":["setup-env.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"setup-env.js","sourceRoot":"src/","sources":["setup-env.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC;AAC1C,OAAO,EAAE,SAAS,IAAI,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,iDAAiD;AACjD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,kBAAkB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C,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAE3F,6CAA6C;IAC7C,OAAO,CAAC,SAAS,CAAC,cAAc,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;IAE3C,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC;AAC3C,CAAC,CAAC,CAAC;AAEH,SAAS,CAAC,GAAG,EAAE;IACb,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC;IAChB,cAAc,EAAE,CAAC;IACjB,YAAY,EAAE,CAAC;IACf,WAAW,EAAE,CAAC;IACd,gBAAgB,EAAE,CAAC;AACrB,CAAC,CAAC,CAAC;AAEH,SAAS,CAAC,KAAK,IAAI,EAAE;IACnB,wGAAwG;IACxG,MAAM,aAAa,EAAE,CAAC;AACxB,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,GAAG,EAAE;IACZ,kCAAkC;IAClC,sBAAsB,EAAE,CAAC;IACzB,sBAAsB,EAAE,CAAC;IACzB,uBAAuB,EAAE,CAAC;IAC1B,qBAAqB,EAAE,CAAC;AAC1B,CAAC,CAAC,CAAC"}
|
package/dist/setup-env.spec.js
CHANGED
|
@@ -13,10 +13,10 @@ it('should stub fetch method', async () => {
|
|
|
13
13
|
await fetch(url);
|
|
14
14
|
expect(fetchSpy).toHaveBeenCalledWith(url);
|
|
15
15
|
});
|
|
16
|
-
it.each([
|
|
16
|
+
it.each(['disconnect', 'observe', 'takeRecords', 'unobserve'])('should stub intersection observer %s method', (method) => {
|
|
17
17
|
const observer = new globalThis.IntersectionObserver(() => ({}), {});
|
|
18
18
|
const methodSpy = vi.spyOn(observer, method);
|
|
19
|
-
observer[method]();
|
|
19
|
+
observer[method](document.createElement('div'));
|
|
20
20
|
expect(methodSpy).toHaveBeenCalled();
|
|
21
21
|
});
|
|
22
22
|
//# sourceMappingURL=setup-env.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-env.spec.js","sourceRoot":"src/","sources":["setup-env.spec.ts"],"names":[],"mappings":";AAAA,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;IACxC,MAAM,GAAG,GAAG,QAAQ,CAAC;IAErB,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEzC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAEvC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEjB,MAAM,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,0BAA0B,EAAE,KAAK,IAAI,EAAE;IACxC,MAAM,GAAG,GAAG,QAAQ,CAAC;IAErB,MAAM,QAAQ,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAE/C,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAExC,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAEjB,MAAM,CAAC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;AAC7C,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"setup-env.spec.js","sourceRoot":"src/","sources":["setup-env.spec.ts"],"names":[],"mappings":";AAAA,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;IACxC,MAAM,GAAG,GAAG,QAAQ,CAAC;IAErB,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEzC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAEvC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEjB,MAAM,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,0BAA0B,EAAE,KAAK,IAAI,EAAE;IACxC,MAAM,GAAG,GAAG,QAAQ,CAAC;IAErB,MAAM,QAAQ,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAE/C,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAExC,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAEjB,MAAM,CAAC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;AAC7C,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,IAAI,CAAyD,CAAC,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CACpH,6CAA6C,EAC7C,CAAC,MAA8D,EAAE,EAAE;IACjE,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,oBAAoB,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAErE,MAAM,SAAS,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAE7C,QAAQ,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IAEhD,MAAM,CAAC,SAAS,CAAC,CAAC,gBAAgB,EAAE,CAAC;AACvC,CAAC,CACF,CAAC"}
|
|
@@ -33,4 +33,23 @@ it('returns a function that can generate a single data object', () => {
|
|
|
33
33
|
bar: 'yak',
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
|
+
it('returns a function that can generate an array of data objects with index of each item', () => {
|
|
37
|
+
const generator = (overrides, index) => ({
|
|
38
|
+
foo: `bar-${index}`,
|
|
39
|
+
bar: `baz-${index}`,
|
|
40
|
+
...overrides,
|
|
41
|
+
});
|
|
42
|
+
expect(createFixtureGenerator(generator)(5)).toEqual([
|
|
43
|
+
{ foo: 'bar-0', bar: 'baz-0' },
|
|
44
|
+
{ foo: 'bar-1', bar: 'baz-1' },
|
|
45
|
+
{ foo: 'bar-2', bar: 'baz-2' },
|
|
46
|
+
{ foo: 'bar-3', bar: 'baz-3' },
|
|
47
|
+
{ foo: 'bar-4', bar: 'baz-4' },
|
|
48
|
+
]);
|
|
49
|
+
expect(createFixtureGenerator(generator)(3, { bar: 'yak' })).toEqual([
|
|
50
|
+
{ foo: 'bar-0', bar: 'yak' },
|
|
51
|
+
{ foo: 'bar-1', bar: 'yak' },
|
|
52
|
+
{ foo: 'bar-2', bar: 'yak' },
|
|
53
|
+
]);
|
|
54
|
+
});
|
|
36
55
|
//# sourceMappingURL=createFixtureGenerator.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFixtureGenerator.spec.js","sourceRoot":"src/","sources":["utils/__tests__/createFixtureGenerator.spec.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,MAAM,2BAA2B,CAAC;AAE/D,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;IACvE,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAChC,GAAG,EAAE,KAAK;QACV,GAAG,EAAE,KAAK;QACV,GAAG,SAAS;KACb,CAAC,CAAC;IAEH,MAAM,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACnD,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE;QAC1B,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE;QAC1B,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAA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OM.
|
|
3
|
+
*
|
|
4
|
+
* @returns void
|
|
5
|
+
*/
|
|
6
|
+
export default function cleanupDialogs(selector?: string): void;
|
|
7
|
+
/**
|
|
8
|
+
* Helper method to remove the dialogs' mount node from the DOM.
|
|
9
|
+
*/
|
|
10
|
+
export declare function cleanupDialogsMountNode(selector?: string): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper method to remove all Stash dialogs from the DOM.
|
|
3
|
+
*
|
|
4
|
+
* @returns void
|
|
5
|
+
*/
|
|
6
|
+
export default function cleanupDialogs(selector = '.stash-dialog') {
|
|
7
|
+
document.querySelectorAll(selector).forEach((elem) => elem.remove());
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Helper method to remove the dialogs' mount node from the DOM.
|
|
11
|
+
*/
|
|
12
|
+
export function cleanupDialogsMountNode(selector = '#stash-dialogs-mount-node') {
|
|
13
|
+
document.querySelector(selector)?.remove();
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=cleanupDialogs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanupDialogs.js","sourceRoot":"src/","sources":["utils/cleanupDialogs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,QAAQ,GAAG,eAAe;IAC/D,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AACvE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAAQ,GAAG,2BAA2B;IAC5E,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;AAC7C,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @returns void
|
|
5
5
|
*/
|
|
6
|
-
export default function cleanupDropdowns() {
|
|
7
|
-
document.querySelectorAll(
|
|
6
|
+
export default function cleanupDropdowns(selector = '.mount-point-container') {
|
|
7
|
+
document.querySelectorAll(selector).forEach((elem) => elem.remove());
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=cleanupDropdowns.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanupDropdowns.js","sourceRoot":"src/","sources":["utils/cleanupDropdowns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB;
|
|
1
|
+
{"version":3,"file":"cleanupDropdowns.js","sourceRoot":"src/","sources":["utils/cleanupDropdowns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,QAAQ,GAAG,wBAAwB;IAC1E,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper method to remove all Stash menus from the DOM.
|
|
3
|
+
*
|
|
4
|
+
* @returns void
|
|
5
|
+
*/
|
|
6
|
+
export default function cleanupMenus(selector?: string): void;
|
|
7
|
+
/**
|
|
8
|
+
* Helper method to remove the menus' mount node from the DOM.
|
|
9
|
+
*/
|
|
10
|
+
export declare function cleanupMenusMountNode(selector?: string): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper method to remove all Stash menus from the DOM.
|
|
3
|
+
*
|
|
4
|
+
* @returns void
|
|
5
|
+
*/
|
|
6
|
+
export default function cleanupMenus(selector = '#stash-menus-mount-node > div') {
|
|
7
|
+
document.querySelectorAll(selector).forEach((elem) => elem.remove());
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Helper method to remove the menus' mount node from the DOM.
|
|
11
|
+
*/
|
|
12
|
+
export function cleanupMenusMountNode(selector = '#stash-menus-mount-node') {
|
|
13
|
+
document.querySelector(selector)?.remove();
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=cleanupMenus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanupMenus.js","sourceRoot":"src/","sources":["utils/cleanupMenus.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,QAAQ,GAAG,+BAA+B;IAC7E,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AACvE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAQ,GAAG,yBAAyB;IACxE,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;AAC7C,CAAC"}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @returns void
|
|
5
5
|
*/
|
|
6
|
-
export default function cleanupModals() {
|
|
7
|
-
document.querySelectorAll(
|
|
6
|
+
export default function cleanupModals(selector = '.stash-modal') {
|
|
7
|
+
document.querySelectorAll(selector).forEach((elem) => elem.remove());
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Helper method to remove the modals' mount node from the DOM.
|
|
11
11
|
*/
|
|
12
12
|
export function cleanupModalsMountNode(selector = '#stash-modals-mount-node') {
|
|
13
|
-
document.
|
|
13
|
+
document.querySelector(selector)?.remove();
|
|
14
14
|
}
|
|
15
15
|
//# sourceMappingURL=cleanupModals.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanupModals.js","sourceRoot":"src/","sources":["utils/cleanupModals.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa;
|
|
1
|
+
{"version":3,"file":"cleanupModals.js","sourceRoot":"src/","sources":["utils/cleanupModals.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,QAAQ,GAAG,cAAc;IAC7D,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AACvE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAQ,GAAG,0BAA0B;IAC1E,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;AAC7C,CAAC"}
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* @returns void
|
|
5
5
|
*/
|
|
6
6
|
export default function cleanupNoty() {
|
|
7
|
-
document.querySelectorAll('.noty_bar').forEach((elem) => elem.
|
|
7
|
+
document.querySelectorAll('.noty_bar').forEach((elem) => elem.remove());
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=cleanupNoty.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanupNoty.js","sourceRoot":"src/","sources":["utils/cleanupNoty.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW;IACjC,QAAQ,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"cleanupNoty.js","sourceRoot":"src/","sources":["utils/cleanupNoty.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW;IACjC,QAAQ,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @returns void
|
|
5
5
|
*/
|
|
6
|
-
export default function cleanupToasts() {
|
|
7
|
-
document.querySelectorAll(
|
|
6
|
+
export default function cleanupToasts(selector = '.stash-toast') {
|
|
7
|
+
document.querySelectorAll(selector).forEach((elem) => elem.remove());
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Helper method to remove the toasts' mount node from the DOM.
|
|
11
11
|
*/
|
|
12
12
|
export function cleanupToastsMountNode(selector = '#stash-toasts-mount-node') {
|
|
13
|
-
document.
|
|
13
|
+
document.querySelector(selector)?.remove();
|
|
14
14
|
}
|
|
15
15
|
//# sourceMappingURL=cleanupToasts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanupToasts.js","sourceRoot":"src/","sources":["utils/cleanupToasts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa;
|
|
1
|
+
{"version":3,"file":"cleanupToasts.js","sourceRoot":"src/","sources":["utils/cleanupToasts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,QAAQ,GAAG,cAAc;IAC7D,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AACvE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAQ,GAAG,0BAA0B;IAC1E,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;AAC7C,CAAC"}
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
* @param fixtureFn - Method that generates a JSON data fixture.
|
|
20
20
|
* @returns A fixture generator that return an array of fixture objects or single object if n = 1.
|
|
21
21
|
*/
|
|
22
|
-
export default function createFixtureGenerator<T>(fixtureFn: (overrides?: Partial<T
|
|
22
|
+
export default function createFixtureGenerator<T>(fixtureFn: (overrides?: Partial<T>, index?: number) => T): {
|
|
23
23
|
(): T;
|
|
24
24
|
<TNum extends 1>(num: TNum, overrides?: Partial<T>): T;
|
|
25
25
|
(num: Partial<T>): T;
|
|
26
|
-
<
|
|
26
|
+
<TNum extends number>(num: TNum, overrides?: Partial<T>): T[];
|
|
27
27
|
};
|
|
@@ -32,7 +32,7 @@ export default function createFixtureGenerator(fixtureFn) {
|
|
|
32
32
|
else {
|
|
33
33
|
// Otherwise, let's generate however many requested data objects
|
|
34
34
|
// eslint-disable-next-line prefer-spread
|
|
35
|
-
return Array.apply(null, Array(num)).map(() => fixtureFn(overrides));
|
|
35
|
+
return Array.apply(null, Array(num)).map((_el, index) => fixtureFn(overrides, index));
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
return _generator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFixtureGenerator.js","sourceRoot":"src/","sources":["utils/createFixtureGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAI,
|
|
1
|
+
{"version":3,"file":"createFixtureGenerator.js","sourceRoot":"src/","sources":["utils/createFixtureGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAI,SAAwD;IAKxG,SAAS,UAAU,CAAC,MAA2B,CAAC,EAAE,SAAS,GAAG,EAAE;QAC9D,+DAA+D;QAC/D,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;aAAM,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;YACrB,wGAAwG;YACxG,OAAO,SAAS,CAAC,SAAS,CAAC,CAAC;QAC9B,CAAC;aAAM,CAAC;YACN,gEAAgE;YAChE,yCAAyC;YACzC,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;QACxF,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leaflink/dom-testing-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-alpha.2",
|
|
4
4
|
"description": "Frontend DOM testing utilities",
|
|
5
|
+
"packageManager": "pnpm@10.12.2",
|
|
5
6
|
"engines": {
|
|
6
|
-
"node": ">=
|
|
7
|
-
"
|
|
7
|
+
"node": ">=24",
|
|
8
|
+
"pnpm": ">=10"
|
|
8
9
|
},
|
|
9
10
|
"exports": {
|
|
10
11
|
".": {
|
|
@@ -33,30 +34,42 @@
|
|
|
33
34
|
],
|
|
34
35
|
"scripts": {
|
|
35
36
|
"build": "tsc",
|
|
36
|
-
"fix": "
|
|
37
|
+
"fix": "pnpm lint --fix",
|
|
37
38
|
"lint": "eslint .",
|
|
38
39
|
"lint:commits": "commitlint",
|
|
39
40
|
"test": "vitest --reporter verbose"
|
|
40
41
|
},
|
|
41
42
|
"license": "MIT",
|
|
42
43
|
"dependencies": {
|
|
43
|
-
"
|
|
44
|
-
"@testing-library/user-event": "^14.5.1",
|
|
45
|
-
"@testing-library/vue": "^7.0.0",
|
|
46
|
-
"msw": "^2.0.8"
|
|
44
|
+
"msw": "^2.7.3"
|
|
47
45
|
},
|
|
48
46
|
"devDependencies": {
|
|
49
|
-
"@
|
|
50
|
-
"
|
|
51
|
-
"
|
|
47
|
+
"@leaflink/eslint-config": "^4.4.2",
|
|
48
|
+
"semantic-release": "^25.0.3",
|
|
49
|
+
"@vitest/coverage-v8": "^3.0.9",
|
|
50
|
+
"commitlint": "^20.3.1",
|
|
51
|
+
"eslint": "^9.39.2",
|
|
52
52
|
"jsdom": "^22.1.0",
|
|
53
|
-
"typescript": "^5.
|
|
54
|
-
"vite": "^
|
|
55
|
-
"vitest": "^0.
|
|
53
|
+
"typescript": "^5.8.2",
|
|
54
|
+
"vite": "^6.2.2",
|
|
55
|
+
"vitest": "^3.0.9"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"@testing-library/dom": "^7 || ^8 || ^9 || ^10",
|
|
59
|
+
"@testing-library/jest-dom": "^5 || ^6",
|
|
60
|
+
"@testing-library/user-event": "^12 || ^13 || ^14",
|
|
61
|
+
"@testing-library/vue": "^7 || ^8",
|
|
62
|
+
"@vue/test-utils": "^2",
|
|
63
|
+
"vue": "^3.2.31"
|
|
56
64
|
},
|
|
57
65
|
"eslintConfig": {
|
|
58
66
|
"extends": [
|
|
59
67
|
"leaflink"
|
|
60
68
|
]
|
|
69
|
+
},
|
|
70
|
+
"commitlint": {
|
|
71
|
+
"extends": [
|
|
72
|
+
"@leaflink/eslint-config/commitlint"
|
|
73
|
+
]
|
|
61
74
|
}
|
|
62
75
|
}
|