@universal-ember/test-support 0.4.0 → 0.5.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/README.md +64 -12
- package/declarations/container/get-service.d.ts +0 -1
- package/declarations/index.d.ts +2 -1
- package/declarations/routing/visit-all.d.ts +0 -1
- package/declarations/template-registry.d.ts +0 -1
- package/declarations/testing/test-helpers-extensions.d.ts +6 -0
- package/declarations/utils.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/testing/test-helpers-extensions.js +26 -0
- package/dist/testing/test-helpers-extensions.js.map +1 -0
- package/dist/utils.js +9 -0
- package/dist/utils.js.map +1 -0
- package/package.json +7 -5
- package/declarations/container/get-service.d.ts.map +0 -1
- package/declarations/index.d.ts.map +0 -1
- package/declarations/routing/visit-all.d.ts.map +0 -1
- package/declarations/template-registry.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,26 +1,78 @@
|
|
|
1
1
|
# test-support
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Common utilities for every app to help making testing easier.
|
|
4
4
|
|
|
5
|
-
## Compatibility
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
- Embroider or ember-auto-import v2
|
|
6
|
+
## `getService`
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
A typed way to get a service.
|
|
11
9
|
|
|
10
|
+
```js
|
|
11
|
+
import { getService } from '@universal-ember/test-support';
|
|
12
|
+
|
|
13
|
+
test('can get a service', async function (assert) {
|
|
14
|
+
let router = getService('router');
|
|
15
|
+
// ^ RouterService
|
|
16
|
+
});
|
|
12
17
|
```
|
|
13
|
-
|
|
18
|
+
|
|
19
|
+
## `noop`
|
|
20
|
+
|
|
21
|
+
a no-op function. literally does nothing.
|
|
22
|
+
|
|
23
|
+
```gjs
|
|
24
|
+
import { noop } from '@universal-ember/test-support';
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
{{ ( noop ) }}
|
|
28
|
+
</template>
|
|
14
29
|
```
|
|
15
30
|
|
|
16
|
-
##
|
|
31
|
+
## `refresh`
|
|
32
|
+
|
|
33
|
+
Simulates refreshing the page without reloading the test window
|
|
17
34
|
|
|
18
|
-
|
|
35
|
+
```js
|
|
36
|
+
import { module, test } from 'qunit';
|
|
37
|
+
import { setupApplicationTest } from 'ember-qunit';
|
|
38
|
+
import { currentURL, visit } from '@ember/test-helpers';
|
|
19
39
|
|
|
20
|
-
|
|
40
|
+
import { refresh } from '@universal-ember/test-support';
|
|
21
41
|
|
|
22
|
-
|
|
42
|
+
module('refresh', function (hooks) {
|
|
43
|
+
setupApplicationTest(hooks);
|
|
44
|
+
|
|
45
|
+
test('are visitable without error', async function (assert) {
|
|
46
|
+
await visit('/foo');
|
|
47
|
+
await refresh(this);
|
|
48
|
+
assert.strictEqual(currentURL(), '/foo');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
```
|
|
23
52
|
|
|
24
|
-
##
|
|
53
|
+
## `visitAllLinks`
|
|
25
54
|
|
|
26
|
-
|
|
55
|
+
Will visit all links, recursively, exhausting every link in your app (excluding external links).
|
|
56
|
+
|
|
57
|
+
This is helpful for making sure that no un-tested pages have errors.
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
import { module, test } from 'qunit';
|
|
61
|
+
import { setupApplicationTest } from 'ember-qunit';
|
|
62
|
+
|
|
63
|
+
import { visitAllLinks } from '@universal-ember/test-support';
|
|
64
|
+
|
|
65
|
+
module('All Links', function (hooks) {
|
|
66
|
+
setupApplicationTest(hooks);
|
|
67
|
+
|
|
68
|
+
test('are visitable without error', async function (assert) {
|
|
69
|
+
const size1 = await visitAllLinks();
|
|
70
|
+
const size2 = await visitAllLinks((url) => {
|
|
71
|
+
assert.ok(url);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
assert.ok(size1 > 0, 'The test app has links');
|
|
75
|
+
assert.ok(size2 > 0, 'The test app has links');
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
```
|
package/declarations/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { currentURL, settled, teardownContext, setupContext, setupApplicationContext, visit } from '@ember/test-helpers';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Simulates reloading the app without reloading the page.
|
|
8
|
+
*
|
|
9
|
+
* Is an alias for the few utilities from `@ember/test-helpers` to teardown an app and re-visit the same page.
|
|
10
|
+
*/
|
|
11
|
+
async function refresh(context) {
|
|
12
|
+
const url = currentURL();
|
|
13
|
+
await settled();
|
|
14
|
+
await teardownContext(context);
|
|
15
|
+
await settled();
|
|
16
|
+
await setupContext(context);
|
|
17
|
+
await settled();
|
|
18
|
+
await setupApplicationContext(context);
|
|
19
|
+
await settled();
|
|
20
|
+
|
|
21
|
+
// Has settled built in
|
|
22
|
+
await visit(url);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { refresh };
|
|
26
|
+
//# sourceMappingURL=test-helpers-extensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-helpers-extensions.js","sources":["../../src/testing/test-helpers-extensions.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n setupContext,\n teardownContext,\n setupApplicationContext,\n visit,\n currentURL,\n settled,\n} from '@ember/test-helpers';\n\n/**\n * Simulates reloading the app without reloading the page.\n *\n * Is an alias for the few utilities from `@ember/test-helpers` to teardown an app and re-visit the same page.\n */\nexport async function refresh(context: any) {\n const url = currentURL();\n\n await settled();\n\n await teardownContext(context);\n await settled();\n\n await setupContext(context);\n await settled();\n\n await setupApplicationContext(context);\n await settled();\n\n // Has settled built in\n await visit(url);\n}\n"],"names":["refresh","context","url","currentURL","settled","teardownContext","setupContext","setupApplicationContext","visit"],"mappings":";;AAAA;;;AAWA;AACA;AACA;AACA;AACA;AACO,eAAeA,OAAOA,CAACC,OAAY,EAAE;AAC1C,EAAA,MAAMC,GAAG,GAAGC,UAAU,EAAE;EAExB,MAAMC,OAAO,EAAE;EAEf,MAAMC,eAAe,CAACJ,OAAO,CAAC;EAC9B,MAAMG,OAAO,EAAE;EAEf,MAAME,YAAY,CAACL,OAAO,CAAC;EAC3B,MAAMG,OAAO,EAAE;EAEf,MAAMG,uBAAuB,CAACN,OAAO,CAAC;EACtC,MAAMG,OAAO,EAAE;;AAEf;EACA,MAAMI,KAAK,CAACN,GAAG,CAAC;AAClB;;;;"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars */\n\n/**\n * A no-op function that literally does nothing.\n */\nexport function noop(...args: any[]): any {}\n"],"names":["noop","args"],"mappings":"AAAA;;AAEA;AACA;AACA;AACO,SAASA,IAAIA,CAAC,GAAGC,IAAW,EAAO;;;;"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@universal-ember/test-support",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "The default blueprint for Embroider v2 addons.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
7
7
|
],
|
|
8
|
-
"repository":
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/universal-ember/test-support.git",
|
|
10
|
+
"directory": "test-support"
|
|
11
|
+
},
|
|
9
12
|
"license": "MIT",
|
|
10
13
|
"author": "",
|
|
11
14
|
"exports": {
|
|
@@ -32,9 +35,8 @@
|
|
|
32
35
|
"dist"
|
|
33
36
|
],
|
|
34
37
|
"dependencies": {
|
|
35
|
-
"@ember/test-helpers": "^4.0.4",
|
|
36
|
-
"@embroider/addon-shim": "^1.8.7"
|
|
37
|
-
"decorator-transforms": "^1.0.1"
|
|
38
|
+
"@ember/test-helpers": "^4.0.4 || ^5.2.2",
|
|
39
|
+
"@embroider/addon-shim": "^1.8.7"
|
|
38
40
|
},
|
|
39
41
|
"devDependencies": {
|
|
40
42
|
"@babel/core": "^7.23.6",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-service.d.ts","sourceRoot":"","sources":["../../src/container/get-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKlE,wBAAgB,UAAU,CAAC,WAAW,SAAS,MAAM,eAAe,EAClE,IAAI,EAAE,WAAW,GAChB,eAAe,CAAC,WAAW,CAAC,CAU9B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"visit-all.d.ts","sourceRoot":"","sources":["../../src/routing/visit-all.ts"],"names":[],"mappings":"AA8CA,wBAAsB,aAAa,CACjC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,mBAkFjD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template-registry.d.ts","sourceRoot":"","sources":["../src/template-registry.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,WAAW,QAAQ;CAEhC"}
|