@universal-ember/test-support 0.1.0 → 0.2.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/declarations/container/get-service.d.ts +3 -0
- package/declarations/container/get-service.d.ts.map +1 -0
- package/declarations/index.d.ts +1 -0
- package/declarations/index.d.ts.map +1 -1
- package/declarations/routing/visit-all.d.ts.map +1 -1
- package/dist/container/get-service.js +15 -0
- package/dist/container/get-service.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/routing/visit-all.js +14 -1
- package/dist/routing/visit-all.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/declarations/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC"}
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visit-all.d.ts","sourceRoot":"","sources":["../../src/routing/visit-all.ts"],"names":[],"mappings":"AAsBA,wBAAsB,aAAa,
|
|
1
|
+
{"version":3,"file":"visit-all.d.ts","sourceRoot":"","sources":["../../src/routing/visit-all.ts"],"names":[],"mappings":"AAsBA,wBAAsB,aAAa,kBAyElC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { assert } from '@ember/debug';
|
|
2
|
+
import { getContext } from '@ember/test-helpers';
|
|
3
|
+
import { getOwner } from '@ember/owner';
|
|
4
|
+
|
|
5
|
+
function getService(name) {
|
|
6
|
+
const context = getContext();
|
|
7
|
+
assert('Could not determine the context for the test', context);
|
|
8
|
+
const owner = context.owner || getOwner(context);
|
|
9
|
+
assert('Could not find the owner on the context', owner);
|
|
10
|
+
const service = owner.lookup(`service:${name}`);
|
|
11
|
+
return service;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { getService };
|
|
15
|
+
//# sourceMappingURL=get-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-service.js","sources":["../../src/container/get-service.ts"],"sourcesContent":["import { assert } from '@ember/debug';\nimport type { Registry as ServiceRegistry } from '@ember/service';\nimport { getContext } from '@ember/test-helpers';\nimport { getOwner } from '@ember/owner';\nimport type Owner from '@ember/owner';\n\nexport function getService<ServiceName extends keyof ServiceRegistry>(\n name: ServiceName,\n): ServiceRegistry[ServiceName] {\n const context = getContext() as { owner?: Owner } | undefined;\n assert('Could not determine the context for the test', context);\n\n const owner = context.owner || getOwner(context);\n assert('Could not find the owner on the context', owner);\n\n const service = owner.lookup(`service:${name}`);\n\n return service;\n}\n"],"names":["getService","name","context","getContext","assert","owner","getOwner","service","lookup"],"mappings":";;;;AAMO,SAASA,UAAUA,CACxBC,IAAiB,EACa;AAC9B,EAAA,MAAMC,OAAO,GAAGC,UAAU,EAAmC,CAAA;AAC7DC,EAAAA,MAAM,CAAC,8CAA8C,EAAEF,OAAO,CAAC,CAAA;EAE/D,MAAMG,KAAK,GAAGH,OAAO,CAACG,KAAK,IAAIC,QAAQ,CAACJ,OAAO,CAAC,CAAA;AAChDE,EAAAA,MAAM,CAAC,yCAAyC,EAAEC,KAAK,CAAC,CAAA;EAExD,MAAME,OAAO,GAAGF,KAAK,CAACG,MAAM,CAAE,CAAA,QAAA,EAAUP,IAAK,CAAA,CAAC,CAAC,CAAA;AAE/C,EAAA,OAAOM,OAAO,CAAA;AAChB;;;;"}
|
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":";"}
|
|
@@ -25,7 +25,20 @@ async function visitAllLinks() {
|
|
|
25
25
|
returnTo = toVisit.changeReturnTo;
|
|
26
26
|
continue;
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
// In-page links are on the page we're already on.
|
|
30
|
+
// As long as we haven't already encountered an error,
|
|
31
|
+
// this is silly to check.
|
|
32
|
+
if (toVisit.startsWith('#')) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const [nonHashPart] = toVisit.split('#');
|
|
36
|
+
|
|
37
|
+
// This was our first page, we've already been here
|
|
38
|
+
if (nonHashPart === '/') {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const key = `${currentURL()}::${nonHashPart}`;
|
|
29
42
|
if (visited.has(key)) continue;
|
|
30
43
|
const result = router.recognize(toVisit);
|
|
31
44
|
if (!result) {
|
|
@@ -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\nfunction findInAppLinks(): string[] {\n return (findAll('a')\n ?.map((link) => link.getAttribute('href'))\n ?.filter((href) => !href?.startsWith('http'))\n .filter(Boolean) || []) as string[];\n}\n\nconst assert = QUnit.assert;\n\nexport async function visitAllLinks() {\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: (string | { 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 (typeof toVisit === 'object' && toVisit !== null) {\n returnTo = toVisit.changeReturnTo;\n continue;\n }\n\n const key = `${currentURL()}::${
|
|
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\nfunction findInAppLinks(): string[] {\n return (findAll('a')\n ?.map((link) => link.getAttribute('href'))\n ?.filter((href) => !href?.startsWith('http'))\n .filter(Boolean) || []) as string[];\n}\n\nconst assert = QUnit.assert;\n\nexport async function visitAllLinks() {\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: (string | { 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 (typeof toVisit === 'object' && toVisit !== null) {\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.startsWith('#')) {\n continue;\n }\n\n const [nonHashPart] = toVisit.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);\n\n if (!result) {\n assert.ok(\n true,\n `${toVisit} 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(`a[href=\"${toVisit}\"]`);\n\n debugAssert(`link exists with ${toVisit}`, link);\n\n await click(link);\n assert.ok(\n currentURL().startsWith(toVisit),\n `Navigation was successful: to:${toVisit}, from:${returnTo}`,\n );\n visited.add(key);\n\n const links = findInAppLinks();\n\n queue.push({ changeReturnTo: currentURL() });\n queue.push(...links);\n }\n}\n"],"names":["findInAppLinks","findAll","map","link","getAttribute","filter","href","startsWith","Boolean","assert","QUnit","visitAllLinks","visited","Set","returnTo","visit","inAppLinks","queue","ctx","getContext","router","owner","lookup","debugAssert","length","toVisit","shift","changeReturnTo","nonHashPart","split","key","currentURL","has","result","recognize","ok","find","click","add","links","push"],"mappings":";;;;AAaA,SAASA,cAAcA,GAAa;AAClC,EAAA,OAAQC,OAAO,CAAC,GAAG,CAAC,EAChBC,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,YAAY,CAAC,MAAM,CAAC,CAAC,EACxCC,MAAM,CAAEC,IAAI,IAAK,CAACA,IAAI,EAAEC,UAAU,CAAC,MAAM,CAAC,CAAC,CAC5CF,MAAM,CAACG,OAAO,CAAC,IAAI,EAAE,CAAA;AAC1B,CAAA;AAEA,MAAMC,MAAM,GAAGC,KAAK,CAACD,MAAM,CAAA;AAEpB,eAAeE,aAAaA,GAAG;AACpC;AACF;AACA;AACE,EAAA,MAAMC,OAAO,GAAG,IAAIC,GAAG,EAAE,CAAA;EACzB,IAAIC,QAAQ,GAAG,GAAG,CAAA;EAElB,MAAMC,KAAK,CAACD,QAAQ,CAAC,CAAA;AAErB,EAAA,MAAME,UAAU,GAAGhB,cAAc,EAAE,CAAA;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