@universal-ember/test-support 0.4.0 → 0.6.0

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 CHANGED
@@ -1,26 +1,78 @@
1
1
  # test-support
2
2
 
3
- [Short description of the addon.]
3
+ Common utilities for every app to help making testing easier.
4
4
 
5
- ## Compatibility
6
5
 
7
- - Ember.js v4.12 or above
8
- - Embroider or ember-auto-import v2
6
+ ## `getService`
9
7
 
10
- ## Installation
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
- ember install test-support
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
- ## Usage
31
+ ## `refresh`
32
+
33
+ Simulates refreshing the page without reloading the test window
17
34
 
18
- [Longer description of how to use the addon in apps.]
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
- ## Contributing
40
+ import { refresh } from '@universal-ember/test-support';
21
41
 
22
- See the [Contributing](CONTRIBUTING.md) guide for details.
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
- ## License
53
+ ## `visitAllLinks`
25
54
 
26
- This project is licensed under the [MIT License](LICENSE.md).
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
+ ```
@@ -1,3 +1,2 @@
1
1
  import type { Registry as ServiceRegistry } from '@ember/service';
2
2
  export declare function getService<ServiceName extends keyof ServiceRegistry>(name: ServiceName): ServiceRegistry[ServiceName];
3
- //# sourceMappingURL=get-service.d.ts.map
@@ -1,3 +1,4 @@
1
1
  export { visitAllLinks } from './routing/visit-all.ts';
2
2
  export { getService } from './container/get-service.ts';
3
- //# sourceMappingURL=index.d.ts.map
3
+ export { noop } from './utils.ts';
4
+ export { refresh } from './testing/test-helpers-extensions.ts';
@@ -1,2 +1 @@
1
- export declare function visitAllLinks(callback?: (url: string) => void | Promise<void>): Promise<number>;
2
- //# sourceMappingURL=visit-all.d.ts.map
1
+ export declare function visitAllLinks(callback?: (url: string) => void | Promise<void>, knownRedirects?: Record<string, string>): Promise<number>;
@@ -1,3 +1,2 @@
1
1
  export default interface Registry {
2
2
  }
3
- //# sourceMappingURL=template-registry.d.ts.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Simulates reloading the app without reloading the page.
3
+ *
4
+ * Is an alias for the few utilities from `@ember/test-helpers` to teardown an app and re-visit the same page.
5
+ */
6
+ export declare function refresh(context: any): Promise<void>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * A no-op function that literally does nothing.
3
+ */
4
+ export declare function noop(...args: any[]): any;
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
1
  export { visitAllLinks } from './routing/visit-all.js';
2
2
  export { getService } from './container/get-service.js';
3
+ export { noop } from './utils.js';
4
+ export { refresh } from './testing/test-helpers-extensions.js';
3
5
  //# sourceMappingURL=index.js.map
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":";;;"}
@@ -21,7 +21,7 @@ function findInAppLinks() {
21
21
  return results;
22
22
  }
23
23
  const assert = QUnit.assert;
24
- async function visitAllLinks(callback) {
24
+ async function visitAllLinks(callback, knownRedirects) {
25
25
  /**
26
26
  * string of "on::target"
27
27
  */
@@ -64,10 +64,12 @@ async function visitAllLinks(callback) {
64
64
  const link = find(toVisit.selector);
65
65
  assert$1(`link exists via selector \`${toVisit.selector}\``, link);
66
66
  await click(link);
67
+ const current = currentURL();
68
+ const expected = knownRedirects?.[current] ?? toVisit.href;
67
69
  assert.pushResult({
68
- result: currentURL().startsWith(toVisit.href),
69
- actual: currentURL(),
70
- expected: toVisit.href,
70
+ result: current.startsWith(expected),
71
+ actual: current,
72
+ expected: expected,
71
73
  message: `Navigation was successful: to:${toVisit.original}, from:${returnTo}`
72
74
  });
73
75
  visited.add(key);
@@ -1 +1 @@
1
- {"version":3,"file":"visit-all.js","sources":["../../src/routing/visit-all.ts"],"sourcesContent":["import { assert as debugAssert } from '@ember/debug';\nimport {\n visit,\n find,\n getContext,\n click,\n currentURL,\n findAll,\n} from '@ember/test-helpers';\nimport QUnit from 'qunit';\nimport type Owner from '@ember/owner';\nimport type RouterService from '@ember/routing/router-service';\n\ninterface InAppLink {\n href: string;\n original: string;\n selector: string;\n}\n\nfunction findInAppLinks(): InAppLink[] {\n const results: InAppLink[] = [];\n\n const allAnchorsOnThePage = findAll('a');\n\n for (const a of allAnchorsOnThePage) {\n const href = a.getAttribute('href');\n\n if (!href) continue;\n if (href.startsWith('http')) continue;\n\n const current = new URL(currentURL(), window.location.origin);\n const url = new URL(href, current);\n const withoutDomain = `${url.pathname}${url.search}${url.hash}`;\n\n results.push({\n href: withoutDomain,\n original: href,\n selector: `a[href=\"${href}\"]`,\n });\n }\n\n return results;\n}\n\nconst assert = QUnit.assert;\n\nexport async function visitAllLinks(\n callback?: (url: string) => void | Promise<void>,\n) {\n /**\n * string of \"on::target\"\n */\n const visited = new Set();\n let returnTo = '/';\n\n await visit(returnTo);\n\n const inAppLinks = findInAppLinks();\n const queue: (InAppLink | { changeReturnTo: string })[] = [...inAppLinks];\n\n const ctx = getContext() as unknown as { owner: Owner };\n const router = ctx?.owner?.lookup('service:router') as RouterService;\n\n debugAssert(`Could not find the router service`, router);\n\n while (queue.length > 0) {\n const toVisit = queue.shift();\n\n debugAssert(`Queue entries cannot be falsey`, toVisit);\n\n if ('changeReturnTo' in toVisit) {\n returnTo = toVisit.changeReturnTo;\n continue;\n }\n\n // In-page links are on the page we're already on.\n // As long as we haven't already encountered an error,\n // this is silly to check.\n if (toVisit.original.startsWith('#')) {\n continue;\n }\n\n const [nonHashPart] = toVisit.href.split('#');\n\n // This was our first page, we've already been here\n if (nonHashPart === '/') {\n continue;\n }\n\n const key = `${currentURL()}::${nonHashPart}`;\n\n if (visited.has(key)) continue;\n\n const result = router.recognize(toVisit.href);\n\n if (!result) {\n assert.ok(\n true,\n `${toVisit.href} on page ${returnTo} is not recognized by this app and will be skipped`,\n );\n continue;\n }\n\n await visit(returnTo);\n\n const link = find(toVisit.selector);\n\n debugAssert(`link exists via selector \\`${toVisit.selector}\\``, link);\n\n await click(link);\n assert.pushResult({\n result: currentURL().startsWith(toVisit.href),\n actual: currentURL(),\n expected: toVisit.href,\n message: `Navigation was successful: to:${toVisit.original}, from:${returnTo}`,\n });\n visited.add(key);\n\n if (callback) {\n await callback(toVisit.href);\n }\n\n const links = findInAppLinks();\n\n queue.push({ changeReturnTo: currentURL() });\n queue.push(...links);\n }\n\n return visited.size;\n}\n"],"names":["findInAppLinks","results","allAnchorsOnThePage","findAll","a","href","getAttribute","startsWith","current","URL","currentURL","window","location","origin","url","withoutDomain","pathname","search","hash","push","original","selector","assert","QUnit","visitAllLinks","callback","visited","Set","returnTo","visit","inAppLinks","queue","ctx","getContext","router","owner","lookup","debugAssert","length","toVisit","shift","changeReturnTo","nonHashPart","split","key","has","result","recognize","ok","link","find","click","pushResult","actual","expected","message","add","links","size"],"mappings":";;;;AAmBA,SAASA,cAAcA,GAAgB;EACrC,MAAMC,OAAoB,GAAG,EAAE;AAE/B,EAAA,MAAMC,mBAAmB,GAAGC,OAAO,CAAC,GAAG,CAAC;AAExC,EAAA,KAAK,MAAMC,CAAC,IAAIF,mBAAmB,EAAE;AACnC,IAAA,MAAMG,IAAI,GAAGD,CAAC,CAACE,YAAY,CAAC,MAAM,CAAC;IAEnC,IAAI,CAACD,IAAI,EAAE;AACX,IAAA,IAAIA,IAAI,CAACE,UAAU,CAAC,MAAM,CAAC,EAAE;AAE7B,IAAA,MAAMC,OAAO,GAAG,IAAIC,GAAG,CAACC,UAAU,EAAE,EAAEC,MAAM,CAACC,QAAQ,CAACC,MAAM,CAAC;IAC7D,MAAMC,GAAG,GAAG,IAAIL,GAAG,CAACJ,IAAI,EAAEG,OAAO,CAAC;AAClC,IAAA,MAAMO,aAAa,GAAG,CAAGD,EAAAA,GAAG,CAACE,QAAQ,CAAA,EAAGF,GAAG,CAACG,MAAM,CAAA,EAAGH,GAAG,CAACI,IAAI,CAAE,CAAA;IAE/DjB,OAAO,CAACkB,IAAI,CAAC;AACXd,MAAAA,IAAI,EAAEU,aAAa;AACnBK,MAAAA,QAAQ,EAAEf,IAAI;MACdgB,QAAQ,EAAE,WAAWhB,IAAI,CAAA,EAAA;AAC3B,KAAC,CAAC;AACJ;AAEA,EAAA,OAAOJ,OAAO;AAChB;AAEA,MAAMqB,MAAM,GAAGC,KAAK,CAACD,MAAM;AAEpB,eAAeE,aAAaA,CACjCC,QAAgD,EAChD;AACA;AACF;AACA;AACE,EAAA,MAAMC,OAAO,GAAG,IAAIC,GAAG,EAAE;EACzB,IAAIC,QAAQ,GAAG,GAAG;EAElB,MAAMC,KAAK,CA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,CACrC,CAAC;AACD,MAAA;AACF;IAEA,MAAMC,KAAK,CAACD,QAAQ,CAAC;AAErB,IAAA,MAAMqB,IAAI,GAAGC,IAAI,CAACX,OAAO,CAAClB,QAAQ,CAAC;IAEnCgB,QAAW,CAAC,8BAA8BE,OAAO,CAAClB,QAAQ,CAAI,EAAA,CAAA,EAAE4B,IAAI,CAAC;IAErE,MAAME,KAAK,CAACF,IAAI,CAAC;IACjB3B,MAAM,CAAC8B,UAAU,CAAC;MAChBN,MAAM,EAAEpC,UAAU,EAAE,CAACH,UAAU,CAACgC,OAAO,CAAClC,IAAI,CAAC;MAC7CgD,MAAM,EAAE3C,UAAU,EAAE;MACpB4C,QAAQ,EAAEf,OAAO,CAAClC,IAAI;AACtBkD,MAAAA,OAAO,EAAE,CAAiChB,8BAAAA,EAAAA,OAAO,CAACnB,QAAQ,UAAUQ,QAAQ,CAAA;AAC9E,KAAC,CAAC;AACFF,IAAAA,OAAO,CAAC8B,GAAG,CAACZ,GAAG,CAAC;AAEhB,IAAA,IAAInB,QAAQ,EAAE;AACZ,MAAA,MAAMA,QAAQ,CAACc,OAAO,CAAClC,IAAI,CAAC;AAC9B;AAEA,IAAA,MAAMoD,KAAK,GAAGzD,cAAc,EAAE;IAE9B+B,KAAK,CAACZ,IAAI,CAAC;MAAEsB,cAAc,EAAE/B,UAAU;AAAG,KAAC,CAAC;AAC5CqB,IAAAA,KAAK,CAACZ,IAAI,CAAC,GAAGsC,KAAK,CAAC;AACtB;EAEA,OAAO/B,OAAO,CAACgC,IAAI;AACrB;;;;"}
1
+ {"version":3,"file":"visit-all.js","sources":["../../src/routing/visit-all.ts"],"sourcesContent":["import { assert as debugAssert } from '@ember/debug';\nimport {\n visit,\n find,\n getContext,\n click,\n currentURL,\n findAll,\n} from '@ember/test-helpers';\nimport QUnit from 'qunit';\nimport type Owner from '@ember/owner';\nimport type RouterService from '@ember/routing/router-service';\n\ninterface InAppLink {\n href: string;\n original: string;\n selector: string;\n}\n\nfunction findInAppLinks(): InAppLink[] {\n const results: InAppLink[] = [];\n\n const allAnchorsOnThePage = findAll('a');\n\n for (const a of allAnchorsOnThePage) {\n const href = a.getAttribute('href');\n\n if (!href) continue;\n if (href.startsWith('http')) continue;\n\n const current = new URL(currentURL(), window.location.origin);\n const url = new URL(href, current);\n const withoutDomain = `${url.pathname}${url.search}${url.hash}`;\n\n results.push({\n href: withoutDomain,\n original: href,\n selector: `a[href=\"${href}\"]`,\n });\n }\n\n return results;\n}\n\nconst assert = QUnit.assert;\n\nexport async function visitAllLinks(\n callback?: (url: string) => void | Promise<void>,\n knownRedirects?: Record<string, string>,\n) {\n /**\n * string of \"on::target\"\n */\n const visited = new Set();\n let returnTo = '/';\n\n await visit(returnTo);\n\n const inAppLinks = findInAppLinks();\n const queue: (InAppLink | { changeReturnTo: string })[] = [...inAppLinks];\n\n const ctx = getContext() as unknown as { owner: Owner };\n const router = ctx?.owner?.lookup('service:router') as RouterService;\n\n debugAssert(`Could not find the router service`, router);\n\n while (queue.length > 0) {\n const toVisit = queue.shift();\n\n debugAssert(`Queue entries cannot be falsey`, toVisit);\n\n if ('changeReturnTo' in toVisit) {\n returnTo = toVisit.changeReturnTo;\n continue;\n }\n\n // In-page links are on the page we're already on.\n // As long as we haven't already encountered an error,\n // this is silly to check.\n if (toVisit.original.startsWith('#')) {\n continue;\n }\n\n const [nonHashPart] = toVisit.href.split('#');\n\n // This was our first page, we've already been here\n if (nonHashPart === '/') {\n continue;\n }\n\n const key = `${currentURL()}::${nonHashPart}`;\n\n if (visited.has(key)) continue;\n\n const result = router.recognize(toVisit.href);\n\n if (!result) {\n assert.ok(\n true,\n `${toVisit.href} on page ${returnTo} is not recognized by this app and will be skipped`,\n );\n continue;\n }\n\n await visit(returnTo);\n\n const link = find(toVisit.selector);\n\n debugAssert(`link exists via selector \\`${toVisit.selector}\\``, link);\n\n await click(link);\n\n const current = currentURL();\n const expected = knownRedirects?.[current] ?? toVisit.href;\n\n assert.pushResult({\n result: current.startsWith(expected),\n actual: current,\n expected: expected,\n message: `Navigation was successful: to:${toVisit.original}, from:${returnTo}`,\n });\n visited.add(key);\n\n if (callback) {\n await callback(toVisit.href);\n }\n\n const links = findInAppLinks();\n\n queue.push({ changeReturnTo: currentURL() });\n queue.push(...links);\n }\n\n return visited.size;\n}\n"],"names":["findInAppLinks","results","allAnchorsOnThePage","findAll","a","href","getAttribute","startsWith","current","URL","currentURL","window","location","origin","url","withoutDomain","pathname","search","hash","push","original","selector","assert","QUnit","visitAllLinks","callback","knownRedirects","visited","Set","returnTo","visit","inAppLinks","queue","ctx","getContext","router","owner","lookup","debugAssert","length","toVisit","shift","changeReturnTo","nonHashPart","split","key","has","result","recognize","ok","link","find","click","expected","pushResult","actual","message","add","links","size"],"mappings":";;;;AAmBA,SAASA,cAAcA,GAAgB;EACrC,MAAMC,OAAoB,GAAG,EAAE;AAE/B,EAAA,MAAMC,mBAAmB,GAAGC,OAAO,CAAC,GAAG,CAAC;AAExC,EAAA,KAAK,MAAMC,CAAC,IAAIF,mBAAmB,EAAE;AACnC,IAAA,MAAMG,IAAI,GAAGD,CAAC,CAACE,YAAY,CAAC,MAAM,CAAC;IAEnC,IAAI,CAACD,IAAI,EAAE;AACX,IAAA,IAAIA,IAAI,CAACE,UAAU,CAAC,MAAM,CAAC,EAAE;AAE7B,IAAA,MAAMC,OAAO,GAAG,IAAIC,GAAG,CAACC,UAAU,EAAE,EAAEC,MAAM,CAACC,QAAQ,CAACC,MAAM,CAAC;IAC7D,MAAMC,GAAG,GAAG,IAAIL,GAAG,CAACJ,IAAI,EAAEG,OAAO,CAAC;AAClC,IAAA,MAAMO,aAAa,GAAG,CAAA,EAAGD,GAAG,CAACE,QAAQ,CAAA,EAAGF,GAAG,CAACG,MAAM,CAAA,EAAGH,GAAG,CAACI,IAAI,CAAA,CAAE;IAE/DjB,OAAO,CAACkB,IAAI,CAAC;AACXd,MAAAA,IAAI,EAAEU,aAAa;AACnBK,MAAAA,QAAQ,EAAEf,IAAI;MACdgB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AE;IAE9BgC,KAAK,CAACb,IAAI,CAAC;MAAEuB,cAAc,EAAEhC,UAAU;AAAG,KAAC,CAAC;AAC5CsB,IAAAA,KAAK,CAACb,IAAI,CAAC,GAAGuC,KAAK,CAAC;AACtB,EAAA;EAEA,OAAO/B,OAAO,CAACgC,IAAI;AACrB;;;;"}
@@ -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,9 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars */
2
+
3
+ /**
4
+ * A no-op function that literally does nothing.
5
+ */
6
+ function noop(...args) {}
7
+
8
+ export { noop };
9
+ //# sourceMappingURL=utils.js.map
@@ -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,CAAC;;;;"}
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@universal-ember/test-support",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
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"}