├── .editorconfig
├── .eslintrc.json
├── .github
└── workflows
│ └── main.yml
├── .gitignore
├── .npmignore
├── CONTRIBUTING.md
├── ISSUE_TEMPLATE.md
├── LICENSE
├── README.md
├── bower.json
├── dist
├── amd
│ ├── aurelia-testing.js
│ └── aurelia-testing.js.map
├── commonjs
│ ├── aurelia-testing.js
│ └── aurelia-testing.js.map
├── es2015
│ ├── aurelia-testing.js
│ └── aurelia-testing.js.map
├── es2017
│ ├── aurelia-testing.js
│ └── aurelia-testing.js.map
├── native-modules
│ ├── aurelia-testing.js
│ └── aurelia-testing.js.map
├── system
│ ├── aurelia-testing.js
│ └── aurelia-testing.js.map
└── types
│ └── aurelia-testing.d.ts
├── doc
├── CHANGELOG.md
├── MAINTAINER.md
├── api.json
├── cleanup.js
├── shape-defs.js
└── shape-doc.js
├── karma.conf.js
├── package-lock.json
├── package.json
├── rollup.config.js
├── src
├── aurelia-testing.ts
├── compile-spy.ts
├── component-tester.ts
├── view-spy.ts
└── wait.ts
├── test
├── component-tester.spec.ts
├── doc-samples.spec.ts
├── resources
│ ├── my-attribute.ts
│ ├── my-component.html
│ └── my-component.ts
├── setup.ts
└── tsconfig.json
├── tsconfig.build.json
├── tsconfig.json
├── tslint.json
└── typings.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: http://EditorConfig.org
2 |
3 | # top-most EditorConfig file
4 | root = true
5 |
6 | # Unix-style newlines with a newline ending every file
7 | [*]
8 | end_of_line = lf
9 | insert_final_newline = true
10 |
11 | # 2 space indentation
12 | [**.*]
13 | indent_style = space
14 | indent_size = 2
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "parser": "@typescript-eslint/parser",
4 | "extends": ["plugin:@typescript-eslint/recommended"],
5 | "ignorePatterns": [
6 | "node_modules",
7 | "dist",
8 | "build",
9 | ".vscode",
10 | "*.config.js",
11 | ".webpack",
12 | "_warmup",
13 | "**/*.js"
14 | ],
15 | "plugins": [],
16 | "parserOptions": {
17 | "ecmaVersion": 2019,
18 | "sourceType": "module"
19 | },
20 | "rules": {
21 | "@typescript-eslint/no-namespace": "off",
22 | "@typescript-eslint/camelcase": "off",
23 | "@typescript-eslint/no-explicit-any": "off",
24 | "@typescript-eslint/explicit-function-return-type": "off",
25 | "@typescript-eslint/no-empty-function": "off",
26 | "@typescript-eslint/consistent-type-assertions": "off",
27 | "@typescript-eslint/ban-ts-ignore": "off",
28 | "@typescript-eslint/no-var-requires": "off",
29 | "@typescript-eslint/explicit-module-boundary-types": "off",
30 | "prefer-const": "off",
31 | "@typescript-eslint/ban-types": "off"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | name: main
2 | on: [push]
3 |
4 | jobs:
5 |
6 | ci:
7 | timeout-minutes: 10
8 | runs-on: ubuntu-latest
9 | steps:
10 | - uses: actions/checkout@v2
11 | - uses: actions/setup-node@v1
12 | with:
13 | node-version: 14
14 | - run: npm ci
15 | - run: npm run cut-release
16 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | jspm_packages
3 | bower_components
4 | .idea
5 | .DS_STORE
6 | *.swp
7 | npm-debug.log*
8 | .test
9 | dist/doc-temp
10 | dist/test
11 | .npmrc
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | jspm_packages
2 | bower_components
3 | .idea
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | We'd love for you to contribute and to make this project even better than it is today! If this interests you, please begin by reading [our contributing guidelines](https://github.com/DurandalProject/about/blob/master/CONTRIBUTING.md). The contributing document will provide you with all the information you need to get started. Once you have read that, you will need to also [sign our CLA](http://goo.gl/forms/dI8QDDSyKR) before we can accept a Pull Request from you. More information on the process is included in the [contributor's guide](https://github.com/DurandalProject/about/blob/master/CONTRIBUTING.md).
4 |
--------------------------------------------------------------------------------
/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
19 | **I'm submitting a bug report**
20 | **I'm submitting a feature request**
21 |
22 | * **Library Version:**
23 | major.minor.patch-pre
24 |
25 |
26 | **Please tell us about your environment:**
27 | * **Operating System:**
28 | OSX 10.x|Linux (distro)|Windows [7|8|8.1|10]
29 |
30 | * **Node Version:**
31 | 6.2.0
32 |
36 |
37 | * **NPM Version:**
38 | 3.8.9
39 |
43 |
44 | * **JSPM OR Webpack AND Version**
45 | JSPM 0.16.32 | webpack 2.1.0-beta.17
46 |
52 |
53 | * **Browser:**
54 | all | Chrome XX | Firefox XX | Edge XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView
55 |
56 | * **Language:**
57 | all | TypeScript X.X | ESNext
58 |
59 |
60 | **Current behavior:**
61 |
62 |
63 | **Expected/desired behavior:**
64 |
71 |
72 |
73 | * **What is the expected behavior?**
74 |
75 |
76 | * **What is the motivation / use case for changing the behavior?**
77 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2010 - 2016 Blue Spire Inc.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | [](https://opensource.org/licenses/MIT)
8 | [](https://www.npmjs.com/package/aurelia-testing)
9 | 
10 | [](https://discourse.aurelia.io)
11 | [](https://twitter.com/intent/follow?screen_name=aureliaeffect)
12 | [](https://discord.gg/RBtyM6u)
13 |
14 | # aurelia-testing
15 |
16 | This library is part of the [Aurelia](http://www.aurelia.io/) platform and contains testing helpers for aurelia app and component developers.
17 |
18 | > To keep up to date on [Aurelia](http://www.aurelia.io/), please visit and subscribe to [the official blog](http://blog.aurelia.io/) and [our email list](http://eepurl.com/ces50j). We also invite you to [follow us on twitter](https://twitter.com/aureliaeffect). If you have questions look around our [Discourse forums](https://discourse.aurelia.io/), chat in our [community on Discord](https://discord.gg/RBtyM6u) or use [stack overflow](http://stackoverflow.com/search?q=aurelia). Documentation can be found [in our developer hub](http://aurelia.io/docs).
19 |
20 | ## Platform Support
21 |
22 | This library can be used in the **browser**.
23 |
24 | ## Building The Code
25 |
26 | To build the code, follow these steps.
27 |
28 | 1. Ensure that [NodeJS](http://nodejs.org/) is installed. This provides the platform on which the build tooling runs.
29 | 2. From the project folder, execute the following command:
30 |
31 | ```shell
32 | npm install
33 | ```
34 | 3. To build the code, you can now run:
35 |
36 | ```shell
37 | npm run build
38 | ```
39 | 4. You will find the compiled code in the `dist` folder, available in six module formats: AMD, CommonJS and ES2015, ES2017, native modules, and System.
40 |
41 | 5. See `package.json` scripts section for other tasks related to generating the docs and linting.
42 |
43 | ## Running The Tests
44 |
45 | To run the unit tests, first ensure that you have followed the steps above in order to install all dependencies and successfully build the library. Once you have done that, you can run the tests by executing the following command:
46 |
47 | ```shell
48 | npm test
49 | ```
50 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "aurelia-testing",
3 | "version": "1.1.0",
4 | "description": "A collection of helpers for testing Aurelia apps and components.",
5 | "keywords": [
6 | "aurelia",
7 | "cache"
8 | ],
9 | "homepage": "http://aurelia.io",
10 | "main": "dist/commonjs/aurelia-testing.js",
11 | "moduleType": "node",
12 | "license": "MIT",
13 | "authors": [
14 | "Rob Eisenberg (http://robeisenberg.com/)"
15 | ],
16 | "repository": {
17 | "type": "git",
18 | "url": "http://github.com/aurelia/testing"
19 | },
20 | "dependencies": {
21 | "aurelia-templating": "^1.0.0",
22 | "aurelia-framework": "^1.0.0",
23 | "aurelia-dependency-injection": "^1.0.0",
24 | "aurelia-logging": "^1.0.0",
25 | "aurelia-pal": "^1.0.0"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/dist/amd/aurelia-testing.js:
--------------------------------------------------------------------------------
1 | define('aurelia-testing', ['exports', 'aurelia-templating', 'aurelia-logging', 'aurelia-pal'], (function (exports, aureliaTemplating, aureliaLogging, aureliaPal) { 'use strict';
2 |
3 | var CompileSpy = (function () {
4 | function CompileSpy(element, instruction) {
5 | aureliaLogging.getLogger('compile-spy').info(element.toString(), instruction);
6 | }
7 | Object.defineProperty(CompileSpy, "inject", {
8 | get: function () { return [aureliaPal.DOM.Element, aureliaTemplating.TargetInstruction]; },
9 | enumerable: false,
10 | configurable: true
11 | });
12 | CompileSpy.$resource = {
13 | type: 'attribute',
14 | name: 'compile-spy'
15 | };
16 | return CompileSpy;
17 | }());
18 |
19 | var ViewSpy = (function () {
20 | function ViewSpy() {
21 | this.logger = aureliaLogging.getLogger('view-spy');
22 | }
23 | ViewSpy.prototype._log = function (lifecycleName, context) {
24 | if (!this.value && lifecycleName === 'created') {
25 | this.logger.info(lifecycleName, this.view);
26 | }
27 | else if (this.value && this.value.indexOf(lifecycleName) !== -1) {
28 | this.logger.info(lifecycleName, this.view, context);
29 | }
30 | };
31 | ViewSpy.prototype.created = function (view) {
32 | this.view = view;
33 | this._log('created');
34 | };
35 | ViewSpy.prototype.bind = function (bindingContext) {
36 | this._log('bind', bindingContext);
37 | };
38 | ViewSpy.prototype.attached = function () {
39 | this._log('attached');
40 | };
41 | ViewSpy.prototype.detached = function () {
42 | this._log('detached');
43 | };
44 | ViewSpy.prototype.unbind = function () {
45 | this._log('unbind');
46 | };
47 | ViewSpy.$resource = {
48 | type: 'attribute',
49 | name: 'view-spy'
50 | };
51 | return ViewSpy;
52 | }());
53 |
54 | /******************************************************************************
55 | Copyright (c) Microsoft Corporation.
56 |
57 | Permission to use, copy, modify, and/or distribute this software for any
58 | purpose with or without fee is hereby granted.
59 |
60 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
61 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
62 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
63 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
64 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
65 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
66 | PERFORMANCE OF THIS SOFTWARE.
67 | ***************************************************************************** */
68 |
69 | var __assign = function() {
70 | __assign = Object.assign || function __assign(t) {
71 | for (var s, i = 1, n = arguments.length; i < n; i++) {
72 | s = arguments[i];
73 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
74 | }
75 | return t;
76 | };
77 | return __assign.apply(this, arguments);
78 | };
79 |
80 | function waitFor(getter, options) {
81 | if (options === void 0) { options = { present: true, interval: 50, timeout: 5000 }; }
82 | var timedOut = false;
83 | options = __assign({ present: true, interval: 50, timeout: 5000 }, options);
84 | function wait() {
85 | var element = getter();
86 | var found = element !== null && (!(element instanceof NodeList) &&
87 | !element.jquery || element.length > 0);
88 | if (!options.present === !found || timedOut) {
89 | return Promise.resolve(element);
90 | }
91 | return new Promise(function (rs) { return setTimeout(rs, options.interval); }).then(wait);
92 | }
93 | return Promise.race([
94 | new Promise(function (_, rj) { return setTimeout(function () {
95 | timedOut = true;
96 | rj(new Error(options.present ? 'Element not found' : 'Element not removed'));
97 | }, options.timeout); }),
98 | wait()
99 | ]);
100 | }
101 | function waitForDocumentElement(selector, options) {
102 | return waitFor(function () { return document.querySelector(selector); }, options);
103 | }
104 | function waitForDocumentElements(selector, options) {
105 | return waitFor(function () { return document.querySelectorAll(selector); }, options);
106 | }
107 |
108 | var StageComponent = (function () {
109 | function StageComponent() {
110 | }
111 | StageComponent.withResources = function (resources) {
112 | if (resources === void 0) { resources = []; }
113 | return new ComponentTester().withResources(resources);
114 | };
115 | return StageComponent;
116 | }());
117 | var ComponentTester = (function () {
118 | function ComponentTester() {
119 | this.resources = [];
120 | }
121 | ComponentTester.prototype.configure = function (aurelia) {
122 | return aurelia.use.standardConfiguration();
123 | };
124 | ComponentTester.prototype.bootstrap = function (configure) {
125 | this.configure = configure;
126 | };
127 | ComponentTester.prototype.withResources = function (resources) {
128 | this.resources = resources;
129 | return this;
130 | };
131 | ComponentTester.prototype.inView = function (html) {
132 | this.html = html;
133 | return this;
134 | };
135 | ComponentTester.prototype.boundTo = function (bindingContext) {
136 | this.bindingContext = bindingContext;
137 | return this;
138 | };
139 | ComponentTester.prototype.manuallyHandleLifecycle = function () {
140 | this._prepareLifecycle();
141 | return this;
142 | };
143 | ComponentTester.prototype.create = function (bootstrap) {
144 | var _this = this;
145 | return bootstrap(function (aurelia) {
146 | return Promise.resolve(_this.configure(aurelia)).then(function () {
147 | if (_this.resources) {
148 | aurelia.use.globalResources(_this.resources);
149 | }
150 | return aurelia.start().then(function () {
151 | _this.host = document.createElement('div');
152 | _this.host.innerHTML = _this.html;
153 | document.body.appendChild(_this.host);
154 | return aurelia.enhance(_this.bindingContext, _this.host).then(function () {
155 | _this.rootView = aurelia.root;
156 | _this.element = _this.host.firstElementChild;
157 | if (aurelia.root.controllers.length) {
158 | _this.viewModel = aurelia.root.controllers[0].viewModel;
159 | }
160 | return new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, 0); });
161 | });
162 | });
163 | });
164 | });
165 | };
166 | ComponentTester.prototype.dispose = function () {
167 | if (this.host === undefined || this.rootView === undefined) {
168 | throw new Error('Cannot call ComponentTester.dispose() before ComponentTester.create()');
169 | }
170 | this.rootView.detached();
171 | this.rootView.unbind();
172 | return this.host.parentNode.removeChild(this.host);
173 | };
174 | ComponentTester.prototype._prepareLifecycle = function () {
175 | var _this = this;
176 | var bindPrototype = aureliaTemplating.View.prototype.bind;
177 | aureliaTemplating.View.prototype.bind = function () { };
178 | this.bind = function (bindingContext) { return new Promise(function (resolve) {
179 | aureliaTemplating.View.prototype.bind = bindPrototype;
180 | if (bindingContext !== undefined) {
181 | _this.bindingContext = bindingContext;
182 | }
183 | _this.rootView.bind(_this.bindingContext);
184 | setTimeout(function () { return resolve(); }, 0);
185 | }); };
186 | var attachedPrototype = aureliaTemplating.View.prototype.attached;
187 | aureliaTemplating.View.prototype.attached = function () { };
188 | this.attached = function () { return new Promise(function (resolve) {
189 | aureliaTemplating.View.prototype.attached = attachedPrototype;
190 | _this.rootView.attached();
191 | setTimeout(function () { return resolve(); }, 0);
192 | }); };
193 | this.detached = function () { return new Promise(function (resolve) {
194 | _this.rootView.detached();
195 | setTimeout(function () { return resolve(); }, 0);
196 | }); };
197 | this.unbind = function () { return new Promise(function (resolve) {
198 | _this.rootView.unbind();
199 | setTimeout(function () { return resolve(); }, 0);
200 | }); };
201 | };
202 | ComponentTester.prototype.waitForElement = function (selector, options) {
203 | var _this = this;
204 | return waitFor(function () { return _this.element.querySelector(selector); }, options);
205 | };
206 | ComponentTester.prototype.waitForElements = function (selector, options) {
207 | var _this = this;
208 | return waitFor(function () { return _this.element.querySelectorAll(selector); }, options);
209 | };
210 | return ComponentTester;
211 | }());
212 |
213 | function configure(config) {
214 | config.globalResources([CompileSpy, ViewSpy]);
215 | }
216 |
217 | exports.CompileSpy = CompileSpy;
218 | exports.ComponentTester = ComponentTester;
219 | exports.StageComponent = StageComponent;
220 | exports.ViewSpy = ViewSpy;
221 | exports.configure = configure;
222 | exports.waitFor = waitFor;
223 | exports.waitForDocumentElement = waitForDocumentElement;
224 | exports.waitForDocumentElements = waitForDocumentElements;
225 |
226 | Object.defineProperty(exports, '__esModule', { value: true });
227 |
228 | }));
229 | //# sourceMappingURL=aurelia-testing.js.map
230 |
--------------------------------------------------------------------------------
/dist/commonjs/aurelia-testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, '__esModule', { value: true });
4 |
5 | var aureliaTemplating = require('aurelia-templating');
6 | var aureliaLogging = require('aurelia-logging');
7 | var aureliaPal = require('aurelia-pal');
8 |
9 | var CompileSpy = (function () {
10 | function CompileSpy(element, instruction) {
11 | aureliaLogging.getLogger('compile-spy').info(element.toString(), instruction);
12 | }
13 | Object.defineProperty(CompileSpy, "inject", {
14 | get: function () { return [aureliaPal.DOM.Element, aureliaTemplating.TargetInstruction]; },
15 | enumerable: false,
16 | configurable: true
17 | });
18 | CompileSpy.$resource = {
19 | type: 'attribute',
20 | name: 'compile-spy'
21 | };
22 | return CompileSpy;
23 | }());
24 |
25 | var ViewSpy = (function () {
26 | function ViewSpy() {
27 | this.logger = aureliaLogging.getLogger('view-spy');
28 | }
29 | ViewSpy.prototype._log = function (lifecycleName, context) {
30 | if (!this.value && lifecycleName === 'created') {
31 | this.logger.info(lifecycleName, this.view);
32 | }
33 | else if (this.value && this.value.indexOf(lifecycleName) !== -1) {
34 | this.logger.info(lifecycleName, this.view, context);
35 | }
36 | };
37 | ViewSpy.prototype.created = function (view) {
38 | this.view = view;
39 | this._log('created');
40 | };
41 | ViewSpy.prototype.bind = function (bindingContext) {
42 | this._log('bind', bindingContext);
43 | };
44 | ViewSpy.prototype.attached = function () {
45 | this._log('attached');
46 | };
47 | ViewSpy.prototype.detached = function () {
48 | this._log('detached');
49 | };
50 | ViewSpy.prototype.unbind = function () {
51 | this._log('unbind');
52 | };
53 | ViewSpy.$resource = {
54 | type: 'attribute',
55 | name: 'view-spy'
56 | };
57 | return ViewSpy;
58 | }());
59 |
60 | /******************************************************************************
61 | Copyright (c) Microsoft Corporation.
62 |
63 | Permission to use, copy, modify, and/or distribute this software for any
64 | purpose with or without fee is hereby granted.
65 |
66 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
67 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
68 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
69 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
70 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
71 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
72 | PERFORMANCE OF THIS SOFTWARE.
73 | ***************************************************************************** */
74 |
75 | var __assign = function() {
76 | __assign = Object.assign || function __assign(t) {
77 | for (var s, i = 1, n = arguments.length; i < n; i++) {
78 | s = arguments[i];
79 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
80 | }
81 | return t;
82 | };
83 | return __assign.apply(this, arguments);
84 | };
85 |
86 | function waitFor(getter, options) {
87 | if (options === void 0) { options = { present: true, interval: 50, timeout: 5000 }; }
88 | var timedOut = false;
89 | options = __assign({ present: true, interval: 50, timeout: 5000 }, options);
90 | function wait() {
91 | var element = getter();
92 | var found = element !== null && (!(element instanceof NodeList) &&
93 | !element.jquery || element.length > 0);
94 | if (!options.present === !found || timedOut) {
95 | return Promise.resolve(element);
96 | }
97 | return new Promise(function (rs) { return setTimeout(rs, options.interval); }).then(wait);
98 | }
99 | return Promise.race([
100 | new Promise(function (_, rj) { return setTimeout(function () {
101 | timedOut = true;
102 | rj(new Error(options.present ? 'Element not found' : 'Element not removed'));
103 | }, options.timeout); }),
104 | wait()
105 | ]);
106 | }
107 | function waitForDocumentElement(selector, options) {
108 | return waitFor(function () { return document.querySelector(selector); }, options);
109 | }
110 | function waitForDocumentElements(selector, options) {
111 | return waitFor(function () { return document.querySelectorAll(selector); }, options);
112 | }
113 |
114 | var StageComponent = (function () {
115 | function StageComponent() {
116 | }
117 | StageComponent.withResources = function (resources) {
118 | if (resources === void 0) { resources = []; }
119 | return new ComponentTester().withResources(resources);
120 | };
121 | return StageComponent;
122 | }());
123 | var ComponentTester = (function () {
124 | function ComponentTester() {
125 | this.resources = [];
126 | }
127 | ComponentTester.prototype.configure = function (aurelia) {
128 | return aurelia.use.standardConfiguration();
129 | };
130 | ComponentTester.prototype.bootstrap = function (configure) {
131 | this.configure = configure;
132 | };
133 | ComponentTester.prototype.withResources = function (resources) {
134 | this.resources = resources;
135 | return this;
136 | };
137 | ComponentTester.prototype.inView = function (html) {
138 | this.html = html;
139 | return this;
140 | };
141 | ComponentTester.prototype.boundTo = function (bindingContext) {
142 | this.bindingContext = bindingContext;
143 | return this;
144 | };
145 | ComponentTester.prototype.manuallyHandleLifecycle = function () {
146 | this._prepareLifecycle();
147 | return this;
148 | };
149 | ComponentTester.prototype.create = function (bootstrap) {
150 | var _this = this;
151 | return bootstrap(function (aurelia) {
152 | return Promise.resolve(_this.configure(aurelia)).then(function () {
153 | if (_this.resources) {
154 | aurelia.use.globalResources(_this.resources);
155 | }
156 | return aurelia.start().then(function () {
157 | _this.host = document.createElement('div');
158 | _this.host.innerHTML = _this.html;
159 | document.body.appendChild(_this.host);
160 | return aurelia.enhance(_this.bindingContext, _this.host).then(function () {
161 | _this.rootView = aurelia.root;
162 | _this.element = _this.host.firstElementChild;
163 | if (aurelia.root.controllers.length) {
164 | _this.viewModel = aurelia.root.controllers[0].viewModel;
165 | }
166 | return new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, 0); });
167 | });
168 | });
169 | });
170 | });
171 | };
172 | ComponentTester.prototype.dispose = function () {
173 | if (this.host === undefined || this.rootView === undefined) {
174 | throw new Error('Cannot call ComponentTester.dispose() before ComponentTester.create()');
175 | }
176 | this.rootView.detached();
177 | this.rootView.unbind();
178 | return this.host.parentNode.removeChild(this.host);
179 | };
180 | ComponentTester.prototype._prepareLifecycle = function () {
181 | var _this = this;
182 | var bindPrototype = aureliaTemplating.View.prototype.bind;
183 | aureliaTemplating.View.prototype.bind = function () { };
184 | this.bind = function (bindingContext) { return new Promise(function (resolve) {
185 | aureliaTemplating.View.prototype.bind = bindPrototype;
186 | if (bindingContext !== undefined) {
187 | _this.bindingContext = bindingContext;
188 | }
189 | _this.rootView.bind(_this.bindingContext);
190 | setTimeout(function () { return resolve(); }, 0);
191 | }); };
192 | var attachedPrototype = aureliaTemplating.View.prototype.attached;
193 | aureliaTemplating.View.prototype.attached = function () { };
194 | this.attached = function () { return new Promise(function (resolve) {
195 | aureliaTemplating.View.prototype.attached = attachedPrototype;
196 | _this.rootView.attached();
197 | setTimeout(function () { return resolve(); }, 0);
198 | }); };
199 | this.detached = function () { return new Promise(function (resolve) {
200 | _this.rootView.detached();
201 | setTimeout(function () { return resolve(); }, 0);
202 | }); };
203 | this.unbind = function () { return new Promise(function (resolve) {
204 | _this.rootView.unbind();
205 | setTimeout(function () { return resolve(); }, 0);
206 | }); };
207 | };
208 | ComponentTester.prototype.waitForElement = function (selector, options) {
209 | var _this = this;
210 | return waitFor(function () { return _this.element.querySelector(selector); }, options);
211 | };
212 | ComponentTester.prototype.waitForElements = function (selector, options) {
213 | var _this = this;
214 | return waitFor(function () { return _this.element.querySelectorAll(selector); }, options);
215 | };
216 | return ComponentTester;
217 | }());
218 |
219 | function configure(config) {
220 | config.globalResources([CompileSpy, ViewSpy]);
221 | }
222 |
223 | exports.CompileSpy = CompileSpy;
224 | exports.ComponentTester = ComponentTester;
225 | exports.StageComponent = StageComponent;
226 | exports.ViewSpy = ViewSpy;
227 | exports.configure = configure;
228 | exports.waitFor = waitFor;
229 | exports.waitForDocumentElement = waitForDocumentElement;
230 | exports.waitForDocumentElements = waitForDocumentElements;
231 | //# sourceMappingURL=aurelia-testing.js.map
232 |
--------------------------------------------------------------------------------
/dist/commonjs/aurelia-testing.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"aurelia-testing.js","sources":["../../src/compile-spy.ts","../../src/view-spy.ts","../../node_modules/tslib/tslib.es6.js","../../src/wait.ts","../../src/component-tester.ts","../../src/aurelia-testing.ts"],"sourcesContent":["import { type IStaticResourceConfig, TargetInstruction } from 'aurelia-templating';\r\nimport { getLogger } from 'aurelia-logging';\r\nimport { DOM } from 'aurelia-pal';\r\n\r\n/**\r\n * Attribute to be placed on any element to have it emit the View Compiler's\r\n * TargetInstruction into the debug console, giving you insight into all the\r\n * parsed bindings, behaviors and event handers for the targeted element.\r\n */\r\nexport class CompileSpy {\r\n /** @internal */\r\n static get inject() { return [DOM.Element, TargetInstruction]; }\r\n /** @internal */\r\n static $resource: IStaticResourceConfig = {\r\n type: 'attribute',\r\n name: 'compile-spy'\r\n }\r\n /**\r\n * Creates and instanse of CompileSpy.\r\n * @param element target element on where attribute is placed on.\r\n * @param instruction instructions for how the target element should be enhanced.\r\n */\r\n constructor(element: Element, instruction: TargetInstruction) {\r\n getLogger('compile-spy').info(element.toString(), instruction);\r\n }\r\n}\r\n","import { IStaticResourceConfig } from 'aurelia-templating';\r\nimport { getLogger, Logger } from 'aurelia-logging';\r\n\r\n/**\r\n * Attribute to be placed on any HTML element in a view to emit the View instance\r\n * to the debug console, giving you insight into the live View instance, including\r\n * all child views, live bindings, behaviors and more.\r\n */\r\nexport class ViewSpy {\r\n static $resource: IStaticResourceConfig = {\r\n type: 'attribute',\r\n name: 'view-spy'\r\n };\r\n\r\n private logger: Logger;\r\n private value: any;\r\n private view: any;\r\n\r\n /**\r\n * Creates a new instance of ViewSpy.\r\n */\r\n constructor() {\r\n this.logger = getLogger('view-spy');\r\n }\r\n\r\n private _log(lifecycleName: string, context?: {}) {\r\n if (!this.value && lifecycleName === 'created') {\r\n this.logger.info(lifecycleName, this.view);\r\n } else if (this.value && this.value.indexOf(lifecycleName) !== -1) {\r\n this.logger.info(lifecycleName, this.view, context);\r\n }\r\n }\r\n\r\n /**\r\n * Invoked when the target view is created.\r\n * @param view The target view.\r\n */\r\n public created(view: any) {\r\n this.view = view;\r\n this._log('created');\r\n }\r\n\r\n /**\r\n * Invoked when the target view is bound.\r\n * @param bindingContext The target view's binding context.\r\n */\r\n public bind(bindingContext: {}) {\r\n this._log('bind', bindingContext);\r\n }\r\n\r\n /**\r\n * Invoked when the target element is attached to the DOM.\r\n */\r\n public attached() {\r\n this._log('attached');\r\n }\r\n\r\n /**\r\n * Invoked when the target element is detached from the DOM.\r\n */\r\n public detached() {\r\n this._log('detached');\r\n }\r\n\r\n /**\r\n * Invoked when the target element is unbound.\r\n */\r\n public unbind() {\r\n this._log('unbind');\r\n }\r\n}\r\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/**\r\n * Generic function to wait for something to happen. Uses polling\r\n * @param getter: a getter function that returns anything else than `null` or an\r\n * empty array or an empty jQuery object when the\r\n * condition is met\r\n * @param options: lookup options, defaults to\r\n * `{present: true, interval: 50, timeout: 5000}`\r\n */\r\nexport function waitFor(getter: () => T, options: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n} = {present: true, interval: 50, timeout: 5000}): Promise {\r\n // prevents infinite recursion if the request times out\r\n let timedOut = false;\r\n\r\n options = {\r\n present: true,\r\n interval: 50,\r\n timeout: 5000,\r\n ...options\r\n };\r\n\r\n function wait(): Promise {\r\n const element = getter();\r\n // boolean is needed here, hence the length > 0\r\n const found = element !== null && (!(element instanceof NodeList) &&\r\n !(element as any).jquery || (element as any).length > 0);\r\n\r\n if (!options.present === !found || timedOut) {\r\n return Promise.resolve(element);\r\n }\r\n\r\n return new Promise(rs => setTimeout(rs, options.interval)).then(wait);\r\n }\r\n\r\n return Promise.race([\r\n new Promise(\r\n (_, rj) => setTimeout(() => {\r\n timedOut = true;\r\n rj(new Error(options.present ? 'Element not found' : 'Element not removed'));\r\n }, options.timeout)\r\n ),\r\n wait()\r\n ]) as Promise;\r\n}\r\n\r\nexport function waitForDocumentElement(selector: string, options?: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n}): Promise {\r\n return waitFor(() => document.querySelector(selector) as Element, options);\r\n}\r\n\r\nexport function waitForDocumentElements(selector: string, options?: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n}): Promise> {\r\n return waitFor(() => document.querySelectorAll(selector), options);\r\n}\r\n","import { View } from 'aurelia-templating';\r\nimport type { Aurelia, FrameworkConfiguration } from 'aurelia-framework';\r\nimport { waitFor } from './wait';\r\n\r\ninterface AureliaWithRoot extends Aurelia {\r\n root: ViewWithControllers;\r\n}\r\n\r\ninterface ViewWithControllers extends View {\r\n controllers: {viewModel: any}[];\r\n}\r\n\r\nexport class StageComponent {\r\n public static withResources(resources: string | string[] = []): ComponentTester {\r\n return new ComponentTester().withResources(resources);\r\n }\r\n}\r\n\r\nexport class ComponentTester {\r\n public bind: (bindingContext: {}) => Promise;\r\n public attached: () => Promise;\r\n public detached: () => Promise;\r\n public unbind: () => Promise;\r\n public element: Element;\r\n public viewModel: T;\r\n\r\n private html: string;\r\n private resources: string | Function | (string | Function)[] = [];\r\n private bindingContext: {};\r\n private rootView: View;\r\n private host: HTMLDivElement;\r\n\r\n public configure(aurelia: Aurelia): FrameworkConfiguration {\r\n return aurelia.use.standardConfiguration();\r\n }\r\n\r\n public bootstrap(configure: (aurelia: Aurelia) => FrameworkConfiguration) {\r\n this.configure = configure;\r\n }\r\n\r\n public withResources(resources: string | string[]): this {\r\n this.resources = resources;\r\n return this;\r\n }\r\n\r\n public inView(html: string): this {\r\n this.html = html;\r\n return this;\r\n }\r\n\r\n public boundTo(bindingContext: {}): this {\r\n this.bindingContext = bindingContext;\r\n return this;\r\n }\r\n\r\n public manuallyHandleLifecycle(): this {\r\n this._prepareLifecycle();\r\n return this;\r\n }\r\n\r\n public create(bootstrap: (configure: (aurelia: Aurelia) => Promise) => Promise): Promise {\r\n return bootstrap((aurelia: AureliaWithRoot) => {\r\n return Promise.resolve(this.configure(aurelia)).then(() => {\r\n if (this.resources) {\r\n aurelia.use.globalResources(this.resources);\r\n }\r\n\r\n return aurelia.start().then(() => {\r\n this.host = document.createElement('div');\r\n this.host.innerHTML = this.html;\r\n\r\n document.body.appendChild(this.host);\r\n\r\n return aurelia.enhance(this.bindingContext, this.host).then(() => {\r\n this.rootView = aurelia.root;\r\n this.element = this.host.firstElementChild as Element;\r\n\r\n if (aurelia.root.controllers.length) {\r\n this.viewModel = aurelia.root.controllers[0].viewModel;\r\n }\r\n\r\n return new Promise(resolve => setTimeout(() => resolve(), 0)) as Promise;\r\n });\r\n });\r\n });\r\n });\r\n }\r\n\r\n public dispose(): Element {\r\n if (this.host === undefined || this.rootView === undefined) {\r\n throw new Error(\r\n 'Cannot call ComponentTester.dispose() before ComponentTester.create()'\r\n );\r\n }\r\n\r\n this.rootView.detached();\r\n this.rootView.unbind();\r\n\r\n return (this.host.parentNode as Node).removeChild(this.host);\r\n }\r\n\r\n private _prepareLifecycle() {\r\n // bind\r\n const bindPrototype = View.prototype.bind;\r\n // tslint:disable-next-line:no-empty\r\n View.prototype.bind = () => {};\r\n this.bind = bindingContext => new Promise(resolve => {\r\n View.prototype.bind = bindPrototype;\r\n if (bindingContext !== undefined) {\r\n this.bindingContext = bindingContext;\r\n }\r\n this.rootView.bind(this.bindingContext);\r\n setTimeout(() => resolve(), 0);\r\n });\r\n\r\n // attached\r\n const attachedPrototype = View.prototype.attached;\r\n // tslint:disable-next-line:no-empty\r\n View.prototype.attached = () => {};\r\n this.attached = () => new Promise(resolve => {\r\n View.prototype.attached = attachedPrototype;\r\n this.rootView.attached();\r\n setTimeout(() => resolve(), 0);\r\n });\r\n\r\n // detached\r\n this.detached = () => new Promise(resolve => {\r\n this.rootView.detached();\r\n setTimeout(() => resolve(), 0);\r\n });\r\n\r\n // unbind\r\n this.unbind = () => new Promise(resolve => {\r\n this.rootView.unbind();\r\n setTimeout(() => resolve(), 0);\r\n });\r\n }\r\n\r\n public waitForElement(selector: string, options?: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n }): Promise {\r\n return waitFor(() => this.element.querySelector(selector) as Element, options);\r\n }\r\n\r\n public waitForElements(selector: string, options?: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n }): Promise> {\r\n return waitFor(() => this.element.querySelectorAll(selector) as NodeListOf, options);\r\n }\r\n}\r\n","import type { FrameworkConfiguration } from 'aurelia-framework';\r\nimport { CompileSpy } from './compile-spy';\r\nimport { ViewSpy } from './view-spy';\r\n\r\nexport * from './compile-spy';\r\nexport * from './view-spy';\r\nexport * from './component-tester';\r\nexport * from './wait';\r\n\r\nexport function configure(config: FrameworkConfiguration) {\r\n config.globalResources([CompileSpy, ViewSpy]);\r\n}\r\n"],"names":["getLogger","DOM","TargetInstruction","View"],"mappings":";;;;;;;;AASA,IAAA,UAAA,IAAA,YAAA;IAaE,SAAY,UAAA,CAAA,OAAgB,EAAE,WAA8B,EAAA;AAC1D,QAAAA,wBAAS,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,WAAW,CAAC,CAAC;KAChE;AAbD,IAAA,MAAA,CAAA,cAAA,CAAW,UAAM,EAAA,QAAA,EAAA;aAAjB,YAAsB,EAAA,OAAO,CAACC,cAAG,CAAC,OAAO,EAAEC,mCAAiB,CAAC,CAAC,EAAE;;;AAAA,KAAA,CAAA,CAAA;AAEzD,IAAA,UAAA,CAAA,SAAS,GAA0B;AACxC,QAAA,IAAI,EAAE,WAAW;AACjB,QAAA,IAAI,EAAE,aAAa;KACpB,CAAA;IASH,OAAC,UAAA,CAAA;AAAA,CAhBD,EAgBC;;ACjBD,IAAA,OAAA,IAAA,YAAA;AAaE,IAAA,SAAA,OAAA,GAAA;AACE,QAAA,IAAI,CAAC,MAAM,GAAGF,wBAAS,CAAC,UAAU,CAAC,CAAC;KACrC;AAEO,IAAA,OAAA,CAAA,SAAA,CAAA,IAAI,GAAZ,UAAa,aAAqB,EAAE,OAAY,EAAA;QAC9C,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,aAA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,SAAA,CAAA,eAAe,GAAtB,UAAuB,QAAgB,EAAE,OAIxC,EAAA;QAJD,IAMC,KAAA,GAAA,IAAA,CAAA;AADC,QAAA,OAAO,OAAO,CAAC,YAAA,EAAM,OAAA,KAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAwB,CAAA,EAAA,EAAE,OAAO,CAAC,CAAC;KAC/F,CAAA;IACH,OAAC,eAAA,CAAA;AAAD,CAAC,EAAA;;AChJK,SAAU,SAAS,CAAC,MAA8B,EAAA;IACtD,MAAM,CAAC,eAAe,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;AAChD;;;;;;;;;;;"}
--------------------------------------------------------------------------------
/dist/es2015/aurelia-testing.js:
--------------------------------------------------------------------------------
1 | import { TargetInstruction, View } from 'aurelia-templating';
2 | import { getLogger } from 'aurelia-logging';
3 | import { DOM } from 'aurelia-pal';
4 |
5 | class CompileSpy {
6 | constructor(element, instruction) {
7 | getLogger('compile-spy').info(element.toString(), instruction);
8 | }
9 | static get inject() { return [DOM.Element, TargetInstruction]; }
10 | }
11 | CompileSpy.$resource = {
12 | type: 'attribute',
13 | name: 'compile-spy'
14 | };
15 |
16 | class ViewSpy {
17 | constructor() {
18 | this.logger = getLogger('view-spy');
19 | }
20 | _log(lifecycleName, context) {
21 | if (!this.value && lifecycleName === 'created') {
22 | this.logger.info(lifecycleName, this.view);
23 | }
24 | else if (this.value && this.value.indexOf(lifecycleName) !== -1) {
25 | this.logger.info(lifecycleName, this.view, context);
26 | }
27 | }
28 | created(view) {
29 | this.view = view;
30 | this._log('created');
31 | }
32 | bind(bindingContext) {
33 | this._log('bind', bindingContext);
34 | }
35 | attached() {
36 | this._log('attached');
37 | }
38 | detached() {
39 | this._log('detached');
40 | }
41 | unbind() {
42 | this._log('unbind');
43 | }
44 | }
45 | ViewSpy.$resource = {
46 | type: 'attribute',
47 | name: 'view-spy'
48 | };
49 |
50 | function waitFor(getter, options = { present: true, interval: 50, timeout: 5000 }) {
51 | let timedOut = false;
52 | options = Object.assign({ present: true, interval: 50, timeout: 5000 }, options);
53 | function wait() {
54 | const element = getter();
55 | const found = element !== null && (!(element instanceof NodeList) &&
56 | !element.jquery || element.length > 0);
57 | if (!options.present === !found || timedOut) {
58 | return Promise.resolve(element);
59 | }
60 | return new Promise(rs => setTimeout(rs, options.interval)).then(wait);
61 | }
62 | return Promise.race([
63 | new Promise((_, rj) => setTimeout(() => {
64 | timedOut = true;
65 | rj(new Error(options.present ? 'Element not found' : 'Element not removed'));
66 | }, options.timeout)),
67 | wait()
68 | ]);
69 | }
70 | function waitForDocumentElement(selector, options) {
71 | return waitFor(() => document.querySelector(selector), options);
72 | }
73 | function waitForDocumentElements(selector, options) {
74 | return waitFor(() => document.querySelectorAll(selector), options);
75 | }
76 |
77 | class StageComponent {
78 | static withResources(resources = []) {
79 | return new ComponentTester().withResources(resources);
80 | }
81 | }
82 | class ComponentTester {
83 | constructor() {
84 | this.resources = [];
85 | }
86 | configure(aurelia) {
87 | return aurelia.use.standardConfiguration();
88 | }
89 | bootstrap(configure) {
90 | this.configure = configure;
91 | }
92 | withResources(resources) {
93 | this.resources = resources;
94 | return this;
95 | }
96 | inView(html) {
97 | this.html = html;
98 | return this;
99 | }
100 | boundTo(bindingContext) {
101 | this.bindingContext = bindingContext;
102 | return this;
103 | }
104 | manuallyHandleLifecycle() {
105 | this._prepareLifecycle();
106 | return this;
107 | }
108 | create(bootstrap) {
109 | return bootstrap((aurelia) => {
110 | return Promise.resolve(this.configure(aurelia)).then(() => {
111 | if (this.resources) {
112 | aurelia.use.globalResources(this.resources);
113 | }
114 | return aurelia.start().then(() => {
115 | this.host = document.createElement('div');
116 | this.host.innerHTML = this.html;
117 | document.body.appendChild(this.host);
118 | return aurelia.enhance(this.bindingContext, this.host).then(() => {
119 | this.rootView = aurelia.root;
120 | this.element = this.host.firstElementChild;
121 | if (aurelia.root.controllers.length) {
122 | this.viewModel = aurelia.root.controllers[0].viewModel;
123 | }
124 | return new Promise(resolve => setTimeout(() => resolve(), 0));
125 | });
126 | });
127 | });
128 | });
129 | }
130 | dispose() {
131 | if (this.host === undefined || this.rootView === undefined) {
132 | throw new Error('Cannot call ComponentTester.dispose() before ComponentTester.create()');
133 | }
134 | this.rootView.detached();
135 | this.rootView.unbind();
136 | return this.host.parentNode.removeChild(this.host);
137 | }
138 | _prepareLifecycle() {
139 | const bindPrototype = View.prototype.bind;
140 | View.prototype.bind = () => { };
141 | this.bind = bindingContext => new Promise(resolve => {
142 | View.prototype.bind = bindPrototype;
143 | if (bindingContext !== undefined) {
144 | this.bindingContext = bindingContext;
145 | }
146 | this.rootView.bind(this.bindingContext);
147 | setTimeout(() => resolve(), 0);
148 | });
149 | const attachedPrototype = View.prototype.attached;
150 | View.prototype.attached = () => { };
151 | this.attached = () => new Promise(resolve => {
152 | View.prototype.attached = attachedPrototype;
153 | this.rootView.attached();
154 | setTimeout(() => resolve(), 0);
155 | });
156 | this.detached = () => new Promise(resolve => {
157 | this.rootView.detached();
158 | setTimeout(() => resolve(), 0);
159 | });
160 | this.unbind = () => new Promise(resolve => {
161 | this.rootView.unbind();
162 | setTimeout(() => resolve(), 0);
163 | });
164 | }
165 | waitForElement(selector, options) {
166 | return waitFor(() => this.element.querySelector(selector), options);
167 | }
168 | waitForElements(selector, options) {
169 | return waitFor(() => this.element.querySelectorAll(selector), options);
170 | }
171 | }
172 |
173 | function configure(config) {
174 | config.globalResources([CompileSpy, ViewSpy]);
175 | }
176 |
177 | export { CompileSpy, ComponentTester, StageComponent, ViewSpy, configure, waitFor, waitForDocumentElement, waitForDocumentElements };
178 | //# sourceMappingURL=aurelia-testing.js.map
179 |
--------------------------------------------------------------------------------
/dist/es2015/aurelia-testing.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"aurelia-testing.js","sources":["../../src/compile-spy.ts","../../src/view-spy.ts","../../src/wait.ts","../../src/component-tester.ts","../../src/aurelia-testing.ts"],"sourcesContent":["import { type IStaticResourceConfig, TargetInstruction } from 'aurelia-templating';\r\nimport { getLogger } from 'aurelia-logging';\r\nimport { DOM } from 'aurelia-pal';\r\n\r\n/**\r\n * Attribute to be placed on any element to have it emit the View Compiler's\r\n * TargetInstruction into the debug console, giving you insight into all the\r\n * parsed bindings, behaviors and event handers for the targeted element.\r\n */\r\nexport class CompileSpy {\r\n /** @internal */\r\n static get inject() { return [DOM.Element, TargetInstruction]; }\r\n /** @internal */\r\n static $resource: IStaticResourceConfig = {\r\n type: 'attribute',\r\n name: 'compile-spy'\r\n }\r\n /**\r\n * Creates and instanse of CompileSpy.\r\n * @param element target element on where attribute is placed on.\r\n * @param instruction instructions for how the target element should be enhanced.\r\n */\r\n constructor(element: Element, instruction: TargetInstruction) {\r\n getLogger('compile-spy').info(element.toString(), instruction);\r\n }\r\n}\r\n","import { IStaticResourceConfig } from 'aurelia-templating';\r\nimport { getLogger, Logger } from 'aurelia-logging';\r\n\r\n/**\r\n * Attribute to be placed on any HTML element in a view to emit the View instance\r\n * to the debug console, giving you insight into the live View instance, including\r\n * all child views, live bindings, behaviors and more.\r\n */\r\nexport class ViewSpy {\r\n static $resource: IStaticResourceConfig = {\r\n type: 'attribute',\r\n name: 'view-spy'\r\n };\r\n\r\n private logger: Logger;\r\n private value: any;\r\n private view: any;\r\n\r\n /**\r\n * Creates a new instance of ViewSpy.\r\n */\r\n constructor() {\r\n this.logger = getLogger('view-spy');\r\n }\r\n\r\n private _log(lifecycleName: string, context?: {}) {\r\n if (!this.value && lifecycleName === 'created') {\r\n this.logger.info(lifecycleName, this.view);\r\n } else if (this.value && this.value.indexOf(lifecycleName) !== -1) {\r\n this.logger.info(lifecycleName, this.view, context);\r\n }\r\n }\r\n\r\n /**\r\n * Invoked when the target view is created.\r\n * @param view The target view.\r\n */\r\n public created(view: any) {\r\n this.view = view;\r\n this._log('created');\r\n }\r\n\r\n /**\r\n * Invoked when the target view is bound.\r\n * @param bindingContext The target view's binding context.\r\n */\r\n public bind(bindingContext: {}) {\r\n this._log('bind', bindingContext);\r\n }\r\n\r\n /**\r\n * Invoked when the target element is attached to the DOM.\r\n */\r\n public attached() {\r\n this._log('attached');\r\n }\r\n\r\n /**\r\n * Invoked when the target element is detached from the DOM.\r\n */\r\n public detached() {\r\n this._log('detached');\r\n }\r\n\r\n /**\r\n * Invoked when the target element is unbound.\r\n */\r\n public unbind() {\r\n this._log('unbind');\r\n }\r\n}\r\n","/**\r\n * Generic function to wait for something to happen. Uses polling\r\n * @param getter: a getter function that returns anything else than `null` or an\r\n * empty array or an empty jQuery object when the\r\n * condition is met\r\n * @param options: lookup options, defaults to\r\n * `{present: true, interval: 50, timeout: 5000}`\r\n */\r\nexport function waitFor(getter: () => T, options: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n} = {present: true, interval: 50, timeout: 5000}): Promise {\r\n // prevents infinite recursion if the request times out\r\n let timedOut = false;\r\n\r\n options = {\r\n present: true,\r\n interval: 50,\r\n timeout: 5000,\r\n ...options\r\n };\r\n\r\n function wait(): Promise {\r\n const element = getter();\r\n // boolean is needed here, hence the length > 0\r\n const found = element !== null && (!(element instanceof NodeList) &&\r\n !(element as any).jquery || (element as any).length > 0);\r\n\r\n if (!options.present === !found || timedOut) {\r\n return Promise.resolve(element);\r\n }\r\n\r\n return new Promise(rs => setTimeout(rs, options.interval)).then(wait);\r\n }\r\n\r\n return Promise.race([\r\n new Promise(\r\n (_, rj) => setTimeout(() => {\r\n timedOut = true;\r\n rj(new Error(options.present ? 'Element not found' : 'Element not removed'));\r\n }, options.timeout)\r\n ),\r\n wait()\r\n ]) as Promise;\r\n}\r\n\r\nexport function waitForDocumentElement(selector: string, options?: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n}): Promise {\r\n return waitFor(() => document.querySelector(selector) as Element, options);\r\n}\r\n\r\nexport function waitForDocumentElements(selector: string, options?: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n}): Promise> {\r\n return waitFor(() => document.querySelectorAll(selector), options);\r\n}\r\n","import { View } from 'aurelia-templating';\r\nimport type { Aurelia, FrameworkConfiguration } from 'aurelia-framework';\r\nimport { waitFor } from './wait';\r\n\r\ninterface AureliaWithRoot extends Aurelia {\r\n root: ViewWithControllers;\r\n}\r\n\r\ninterface ViewWithControllers extends View {\r\n controllers: {viewModel: any}[];\r\n}\r\n\r\nexport class StageComponent {\r\n public static withResources(resources: string | string[] = []): ComponentTester {\r\n return new ComponentTester().withResources(resources);\r\n }\r\n}\r\n\r\nexport class ComponentTester {\r\n public bind: (bindingContext: {}) => Promise;\r\n public attached: () => Promise;\r\n public detached: () => Promise;\r\n public unbind: () => Promise;\r\n public element: Element;\r\n public viewModel: T;\r\n\r\n private html: string;\r\n private resources: string | Function | (string | Function)[] = [];\r\n private bindingContext: {};\r\n private rootView: View;\r\n private host: HTMLDivElement;\r\n\r\n public configure(aurelia: Aurelia): FrameworkConfiguration {\r\n return aurelia.use.standardConfiguration();\r\n }\r\n\r\n public bootstrap(configure: (aurelia: Aurelia) => FrameworkConfiguration) {\r\n this.configure = configure;\r\n }\r\n\r\n public withResources(resources: string | string[]): this {\r\n this.resources = resources;\r\n return this;\r\n }\r\n\r\n public inView(html: string): this {\r\n this.html = html;\r\n return this;\r\n }\r\n\r\n public boundTo(bindingContext: {}): this {\r\n this.bindingContext = bindingContext;\r\n return this;\r\n }\r\n\r\n public manuallyHandleLifecycle(): this {\r\n this._prepareLifecycle();\r\n return this;\r\n }\r\n\r\n public create(bootstrap: (configure: (aurelia: Aurelia) => Promise) => Promise): Promise {\r\n return bootstrap((aurelia: AureliaWithRoot) => {\r\n return Promise.resolve(this.configure(aurelia)).then(() => {\r\n if (this.resources) {\r\n aurelia.use.globalResources(this.resources);\r\n }\r\n\r\n return aurelia.start().then(() => {\r\n this.host = document.createElement('div');\r\n this.host.innerHTML = this.html;\r\n\r\n document.body.appendChild(this.host);\r\n\r\n return aurelia.enhance(this.bindingContext, this.host).then(() => {\r\n this.rootView = aurelia.root;\r\n this.element = this.host.firstElementChild as Element;\r\n\r\n if (aurelia.root.controllers.length) {\r\n this.viewModel = aurelia.root.controllers[0].viewModel;\r\n }\r\n\r\n return new Promise(resolve => setTimeout(() => resolve(), 0)) as Promise;\r\n });\r\n });\r\n });\r\n });\r\n }\r\n\r\n public dispose(): Element {\r\n if (this.host === undefined || this.rootView === undefined) {\r\n throw new Error(\r\n 'Cannot call ComponentTester.dispose() before ComponentTester.create()'\r\n );\r\n }\r\n\r\n this.rootView.detached();\r\n this.rootView.unbind();\r\n\r\n return (this.host.parentNode as Node).removeChild(this.host);\r\n }\r\n\r\n private _prepareLifecycle() {\r\n // bind\r\n const bindPrototype = View.prototype.bind;\r\n // tslint:disable-next-line:no-empty\r\n View.prototype.bind = () => {};\r\n this.bind = bindingContext => new Promise(resolve => {\r\n View.prototype.bind = bindPrototype;\r\n if (bindingContext !== undefined) {\r\n this.bindingContext = bindingContext;\r\n }\r\n this.rootView.bind(this.bindingContext);\r\n setTimeout(() => resolve(), 0);\r\n });\r\n\r\n // attached\r\n const attachedPrototype = View.prototype.attached;\r\n // tslint:disable-next-line:no-empty\r\n View.prototype.attached = () => {};\r\n this.attached = () => new Promise(resolve => {\r\n View.prototype.attached = attachedPrototype;\r\n this.rootView.attached();\r\n setTimeout(() => resolve(), 0);\r\n });\r\n\r\n // detached\r\n this.detached = () => new Promise(resolve => {\r\n this.rootView.detached();\r\n setTimeout(() => resolve(), 0);\r\n });\r\n\r\n // unbind\r\n this.unbind = () => new Promise(resolve => {\r\n this.rootView.unbind();\r\n setTimeout(() => resolve(), 0);\r\n });\r\n }\r\n\r\n public waitForElement(selector: string, options?: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n }): Promise {\r\n return waitFor(() => this.element.querySelector(selector) as Element, options);\r\n }\r\n\r\n public waitForElements(selector: string, options?: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n }): Promise> {\r\n return waitFor(() => this.element.querySelectorAll(selector) as NodeListOf, options);\r\n }\r\n}\r\n","import type { FrameworkConfiguration } from 'aurelia-framework';\r\nimport { CompileSpy } from './compile-spy';\r\nimport { ViewSpy } from './view-spy';\r\n\r\nexport * from './compile-spy';\r\nexport * from './view-spy';\r\nexport * from './component-tester';\r\nexport * from './wait';\r\n\r\nexport function configure(config: FrameworkConfiguration) {\r\n config.globalResources([CompileSpy, ViewSpy]);\r\n}\r\n"],"names":[],"mappings":";;;;MASa,UAAU,CAAA;IAarB,WAAY,CAAA,OAAgB,EAAE,WAA8B,EAAA;AAC1D,QAAA,SAAS,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,WAAW,CAAC,CAAC;KAChE;AAbD,IAAA,WAAW,MAAM,GAAK,EAAA,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,EAAE;;AAEzD,UAAA,CAAA,SAAS,GAA0B;AACxC,IAAA,IAAI,EAAE,WAAW;AACjB,IAAA,IAAI,EAAE,aAAa;CACpB;;MCRU,OAAO,CAAA;AAalB,IAAA,WAAA,GAAA;AACE,QAAA,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;KACrC;IAEO,IAAI,CAAC,aAAqB,EAAE,OAAY,EAAA;QAC9C,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,aAAa,KAAK,SAAS,EAAE;YAC9C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5C,SAAA;AAAM,aAAA,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE;AACjE,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACrD,SAAA;KACF;AAMM,IAAA,OAAO,CAAC,IAAS,EAAA;AACtB,QAAA,IAAI,CAAC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AAE,OAIxC,EAAA;AACC,QAAA,OAAO,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAwB,EAAE,OAAO,CAAC,CAAC;KAC/F;AACF;;AChJK,SAAU,SAAS,CAAC,MAA8B,EAAA;IACtD,MAAM,CAAC,eAAe,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;AAChD;;;;"}
--------------------------------------------------------------------------------
/dist/es2017/aurelia-testing.js:
--------------------------------------------------------------------------------
1 | import { TargetInstruction, View } from 'aurelia-templating';
2 | import { getLogger } from 'aurelia-logging';
3 | import { DOM } from 'aurelia-pal';
4 |
5 | class CompileSpy {
6 | constructor(element, instruction) {
7 | getLogger('compile-spy').info(element.toString(), instruction);
8 | }
9 | static get inject() { return [DOM.Element, TargetInstruction]; }
10 | }
11 | CompileSpy.$resource = {
12 | type: 'attribute',
13 | name: 'compile-spy'
14 | };
15 |
16 | class ViewSpy {
17 | constructor() {
18 | this.logger = getLogger('view-spy');
19 | }
20 | _log(lifecycleName, context) {
21 | if (!this.value && lifecycleName === 'created') {
22 | this.logger.info(lifecycleName, this.view);
23 | }
24 | else if (this.value && this.value.indexOf(lifecycleName) !== -1) {
25 | this.logger.info(lifecycleName, this.view, context);
26 | }
27 | }
28 | created(view) {
29 | this.view = view;
30 | this._log('created');
31 | }
32 | bind(bindingContext) {
33 | this._log('bind', bindingContext);
34 | }
35 | attached() {
36 | this._log('attached');
37 | }
38 | detached() {
39 | this._log('detached');
40 | }
41 | unbind() {
42 | this._log('unbind');
43 | }
44 | }
45 | ViewSpy.$resource = {
46 | type: 'attribute',
47 | name: 'view-spy'
48 | };
49 |
50 | function waitFor(getter, options = { present: true, interval: 50, timeout: 5000 }) {
51 | let timedOut = false;
52 | options = Object.assign({ present: true, interval: 50, timeout: 5000 }, options);
53 | function wait() {
54 | const element = getter();
55 | const found = element !== null && (!(element instanceof NodeList) &&
56 | !element.jquery || element.length > 0);
57 | if (!options.present === !found || timedOut) {
58 | return Promise.resolve(element);
59 | }
60 | return new Promise(rs => setTimeout(rs, options.interval)).then(wait);
61 | }
62 | return Promise.race([
63 | new Promise((_, rj) => setTimeout(() => {
64 | timedOut = true;
65 | rj(new Error(options.present ? 'Element not found' : 'Element not removed'));
66 | }, options.timeout)),
67 | wait()
68 | ]);
69 | }
70 | function waitForDocumentElement(selector, options) {
71 | return waitFor(() => document.querySelector(selector), options);
72 | }
73 | function waitForDocumentElements(selector, options) {
74 | return waitFor(() => document.querySelectorAll(selector), options);
75 | }
76 |
77 | class StageComponent {
78 | static withResources(resources = []) {
79 | return new ComponentTester().withResources(resources);
80 | }
81 | }
82 | class ComponentTester {
83 | constructor() {
84 | this.resources = [];
85 | }
86 | configure(aurelia) {
87 | return aurelia.use.standardConfiguration();
88 | }
89 | bootstrap(configure) {
90 | this.configure = configure;
91 | }
92 | withResources(resources) {
93 | this.resources = resources;
94 | return this;
95 | }
96 | inView(html) {
97 | this.html = html;
98 | return this;
99 | }
100 | boundTo(bindingContext) {
101 | this.bindingContext = bindingContext;
102 | return this;
103 | }
104 | manuallyHandleLifecycle() {
105 | this._prepareLifecycle();
106 | return this;
107 | }
108 | create(bootstrap) {
109 | return bootstrap((aurelia) => {
110 | return Promise.resolve(this.configure(aurelia)).then(() => {
111 | if (this.resources) {
112 | aurelia.use.globalResources(this.resources);
113 | }
114 | return aurelia.start().then(() => {
115 | this.host = document.createElement('div');
116 | this.host.innerHTML = this.html;
117 | document.body.appendChild(this.host);
118 | return aurelia.enhance(this.bindingContext, this.host).then(() => {
119 | this.rootView = aurelia.root;
120 | this.element = this.host.firstElementChild;
121 | if (aurelia.root.controllers.length) {
122 | this.viewModel = aurelia.root.controllers[0].viewModel;
123 | }
124 | return new Promise(resolve => setTimeout(() => resolve(), 0));
125 | });
126 | });
127 | });
128 | });
129 | }
130 | dispose() {
131 | if (this.host === undefined || this.rootView === undefined) {
132 | throw new Error('Cannot call ComponentTester.dispose() before ComponentTester.create()');
133 | }
134 | this.rootView.detached();
135 | this.rootView.unbind();
136 | return this.host.parentNode.removeChild(this.host);
137 | }
138 | _prepareLifecycle() {
139 | const bindPrototype = View.prototype.bind;
140 | View.prototype.bind = () => { };
141 | this.bind = bindingContext => new Promise(resolve => {
142 | View.prototype.bind = bindPrototype;
143 | if (bindingContext !== undefined) {
144 | this.bindingContext = bindingContext;
145 | }
146 | this.rootView.bind(this.bindingContext);
147 | setTimeout(() => resolve(), 0);
148 | });
149 | const attachedPrototype = View.prototype.attached;
150 | View.prototype.attached = () => { };
151 | this.attached = () => new Promise(resolve => {
152 | View.prototype.attached = attachedPrototype;
153 | this.rootView.attached();
154 | setTimeout(() => resolve(), 0);
155 | });
156 | this.detached = () => new Promise(resolve => {
157 | this.rootView.detached();
158 | setTimeout(() => resolve(), 0);
159 | });
160 | this.unbind = () => new Promise(resolve => {
161 | this.rootView.unbind();
162 | setTimeout(() => resolve(), 0);
163 | });
164 | }
165 | waitForElement(selector, options) {
166 | return waitFor(() => this.element.querySelector(selector), options);
167 | }
168 | waitForElements(selector, options) {
169 | return waitFor(() => this.element.querySelectorAll(selector), options);
170 | }
171 | }
172 |
173 | function configure(config) {
174 | config.globalResources([CompileSpy, ViewSpy]);
175 | }
176 |
177 | export { CompileSpy, ComponentTester, StageComponent, ViewSpy, configure, waitFor, waitForDocumentElement, waitForDocumentElements };
178 | //# sourceMappingURL=aurelia-testing.js.map
179 |
--------------------------------------------------------------------------------
/dist/es2017/aurelia-testing.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"aurelia-testing.js","sources":["../../src/compile-spy.ts","../../src/view-spy.ts","../../src/wait.ts","../../src/component-tester.ts","../../src/aurelia-testing.ts"],"sourcesContent":["import { type IStaticResourceConfig, TargetInstruction } from 'aurelia-templating';\r\nimport { getLogger } from 'aurelia-logging';\r\nimport { DOM } from 'aurelia-pal';\r\n\r\n/**\r\n * Attribute to be placed on any element to have it emit the View Compiler's\r\n * TargetInstruction into the debug console, giving you insight into all the\r\n * parsed bindings, behaviors and event handers for the targeted element.\r\n */\r\nexport class CompileSpy {\r\n /** @internal */\r\n static get inject() { return [DOM.Element, TargetInstruction]; }\r\n /** @internal */\r\n static $resource: IStaticResourceConfig = {\r\n type: 'attribute',\r\n name: 'compile-spy'\r\n }\r\n /**\r\n * Creates and instanse of CompileSpy.\r\n * @param element target element on where attribute is placed on.\r\n * @param instruction instructions for how the target element should be enhanced.\r\n */\r\n constructor(element: Element, instruction: TargetInstruction) {\r\n getLogger('compile-spy').info(element.toString(), instruction);\r\n }\r\n}\r\n","import { IStaticResourceConfig } from 'aurelia-templating';\r\nimport { getLogger, Logger } from 'aurelia-logging';\r\n\r\n/**\r\n * Attribute to be placed on any HTML element in a view to emit the View instance\r\n * to the debug console, giving you insight into the live View instance, including\r\n * all child views, live bindings, behaviors and more.\r\n */\r\nexport class ViewSpy {\r\n static $resource: IStaticResourceConfig = {\r\n type: 'attribute',\r\n name: 'view-spy'\r\n };\r\n\r\n private logger: Logger;\r\n private value: any;\r\n private view: any;\r\n\r\n /**\r\n * Creates a new instance of ViewSpy.\r\n */\r\n constructor() {\r\n this.logger = getLogger('view-spy');\r\n }\r\n\r\n private _log(lifecycleName: string, context?: {}) {\r\n if (!this.value && lifecycleName === 'created') {\r\n this.logger.info(lifecycleName, this.view);\r\n } else if (this.value && this.value.indexOf(lifecycleName) !== -1) {\r\n this.logger.info(lifecycleName, this.view, context);\r\n }\r\n }\r\n\r\n /**\r\n * Invoked when the target view is created.\r\n * @param view The target view.\r\n */\r\n public created(view: any) {\r\n this.view = view;\r\n this._log('created');\r\n }\r\n\r\n /**\r\n * Invoked when the target view is bound.\r\n * @param bindingContext The target view's binding context.\r\n */\r\n public bind(bindingContext: {}) {\r\n this._log('bind', bindingContext);\r\n }\r\n\r\n /**\r\n * Invoked when the target element is attached to the DOM.\r\n */\r\n public attached() {\r\n this._log('attached');\r\n }\r\n\r\n /**\r\n * Invoked when the target element is detached from the DOM.\r\n */\r\n public detached() {\r\n this._log('detached');\r\n }\r\n\r\n /**\r\n * Invoked when the target element is unbound.\r\n */\r\n public unbind() {\r\n this._log('unbind');\r\n }\r\n}\r\n","/**\r\n * Generic function to wait for something to happen. Uses polling\r\n * @param getter: a getter function that returns anything else than `null` or an\r\n * empty array or an empty jQuery object when the\r\n * condition is met\r\n * @param options: lookup options, defaults to\r\n * `{present: true, interval: 50, timeout: 5000}`\r\n */\r\nexport function waitFor(getter: () => T, options: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n} = {present: true, interval: 50, timeout: 5000}): Promise {\r\n // prevents infinite recursion if the request times out\r\n let timedOut = false;\r\n\r\n options = {\r\n present: true,\r\n interval: 50,\r\n timeout: 5000,\r\n ...options\r\n };\r\n\r\n function wait(): Promise {\r\n const element = getter();\r\n // boolean is needed here, hence the length > 0\r\n const found = element !== null && (!(element instanceof NodeList) &&\r\n !(element as any).jquery || (element as any).length > 0);\r\n\r\n if (!options.present === !found || timedOut) {\r\n return Promise.resolve(element);\r\n }\r\n\r\n return new Promise(rs => setTimeout(rs, options.interval)).then(wait);\r\n }\r\n\r\n return Promise.race([\r\n new Promise(\r\n (_, rj) => setTimeout(() => {\r\n timedOut = true;\r\n rj(new Error(options.present ? 'Element not found' : 'Element not removed'));\r\n }, options.timeout)\r\n ),\r\n wait()\r\n ]) as Promise;\r\n}\r\n\r\nexport function waitForDocumentElement(selector: string, options?: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n}): Promise {\r\n return waitFor(() => document.querySelector(selector) as Element, options);\r\n}\r\n\r\nexport function waitForDocumentElements(selector: string, options?: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n}): Promise> {\r\n return waitFor(() => document.querySelectorAll(selector), options);\r\n}\r\n","import { View } from 'aurelia-templating';\r\nimport type { Aurelia, FrameworkConfiguration } from 'aurelia-framework';\r\nimport { waitFor } from './wait';\r\n\r\ninterface AureliaWithRoot extends Aurelia {\r\n root: ViewWithControllers;\r\n}\r\n\r\ninterface ViewWithControllers extends View {\r\n controllers: {viewModel: any}[];\r\n}\r\n\r\nexport class StageComponent {\r\n public static withResources(resources: string | string[] = []): ComponentTester {\r\n return new ComponentTester().withResources(resources);\r\n }\r\n}\r\n\r\nexport class ComponentTester {\r\n public bind: (bindingContext: {}) => Promise;\r\n public attached: () => Promise;\r\n public detached: () => Promise;\r\n public unbind: () => Promise;\r\n public element: Element;\r\n public viewModel: T;\r\n\r\n private html: string;\r\n private resources: string | Function | (string | Function)[] = [];\r\n private bindingContext: {};\r\n private rootView: View;\r\n private host: HTMLDivElement;\r\n\r\n public configure(aurelia: Aurelia): FrameworkConfiguration {\r\n return aurelia.use.standardConfiguration();\r\n }\r\n\r\n public bootstrap(configure: (aurelia: Aurelia) => FrameworkConfiguration) {\r\n this.configure = configure;\r\n }\r\n\r\n public withResources(resources: string | string[]): this {\r\n this.resources = resources;\r\n return this;\r\n }\r\n\r\n public inView(html: string): this {\r\n this.html = html;\r\n return this;\r\n }\r\n\r\n public boundTo(bindingContext: {}): this {\r\n this.bindingContext = bindingContext;\r\n return this;\r\n }\r\n\r\n public manuallyHandleLifecycle(): this {\r\n this._prepareLifecycle();\r\n return this;\r\n }\r\n\r\n public create(bootstrap: (configure: (aurelia: Aurelia) => Promise) => Promise): Promise {\r\n return bootstrap((aurelia: AureliaWithRoot) => {\r\n return Promise.resolve(this.configure(aurelia)).then(() => {\r\n if (this.resources) {\r\n aurelia.use.globalResources(this.resources);\r\n }\r\n\r\n return aurelia.start().then(() => {\r\n this.host = document.createElement('div');\r\n this.host.innerHTML = this.html;\r\n\r\n document.body.appendChild(this.host);\r\n\r\n return aurelia.enhance(this.bindingContext, this.host).then(() => {\r\n this.rootView = aurelia.root;\r\n this.element = this.host.firstElementChild as Element;\r\n\r\n if (aurelia.root.controllers.length) {\r\n this.viewModel = aurelia.root.controllers[0].viewModel;\r\n }\r\n\r\n return new Promise(resolve => setTimeout(() => resolve(), 0)) as Promise;\r\n });\r\n });\r\n });\r\n });\r\n }\r\n\r\n public dispose(): Element {\r\n if (this.host === undefined || this.rootView === undefined) {\r\n throw new Error(\r\n 'Cannot call ComponentTester.dispose() before ComponentTester.create()'\r\n );\r\n }\r\n\r\n this.rootView.detached();\r\n this.rootView.unbind();\r\n\r\n return (this.host.parentNode as Node).removeChild(this.host);\r\n }\r\n\r\n private _prepareLifecycle() {\r\n // bind\r\n const bindPrototype = View.prototype.bind;\r\n // tslint:disable-next-line:no-empty\r\n View.prototype.bind = () => {};\r\n this.bind = bindingContext => new Promise(resolve => {\r\n View.prototype.bind = bindPrototype;\r\n if (bindingContext !== undefined) {\r\n this.bindingContext = bindingContext;\r\n }\r\n this.rootView.bind(this.bindingContext);\r\n setTimeout(() => resolve(), 0);\r\n });\r\n\r\n // attached\r\n const attachedPrototype = View.prototype.attached;\r\n // tslint:disable-next-line:no-empty\r\n View.prototype.attached = () => {};\r\n this.attached = () => new Promise(resolve => {\r\n View.prototype.attached = attachedPrototype;\r\n this.rootView.attached();\r\n setTimeout(() => resolve(), 0);\r\n });\r\n\r\n // detached\r\n this.detached = () => new Promise(resolve => {\r\n this.rootView.detached();\r\n setTimeout(() => resolve(), 0);\r\n });\r\n\r\n // unbind\r\n this.unbind = () => new Promise(resolve => {\r\n this.rootView.unbind();\r\n setTimeout(() => resolve(), 0);\r\n });\r\n }\r\n\r\n public waitForElement(selector: string, options?: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n }): Promise {\r\n return waitFor(() => this.element.querySelector(selector) as Element, options);\r\n }\r\n\r\n public waitForElements(selector: string, options?: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n }): Promise> {\r\n return waitFor(() => this.element.querySelectorAll(selector) as NodeListOf, options);\r\n }\r\n}\r\n","import type { FrameworkConfiguration } from 'aurelia-framework';\r\nimport { CompileSpy } from './compile-spy';\r\nimport { ViewSpy } from './view-spy';\r\n\r\nexport * from './compile-spy';\r\nexport * from './view-spy';\r\nexport * from './component-tester';\r\nexport * from './wait';\r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U,SAAS,CAAC,MAA8B,EAAA;IACtD,MAAM,CAAC,eAAe,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;AAChD;;;;"}
--------------------------------------------------------------------------------
/dist/native-modules/aurelia-testing.js:
--------------------------------------------------------------------------------
1 | import { TargetInstruction, View } from 'aurelia-templating';
2 | import { getLogger } from 'aurelia-logging';
3 | import { DOM } from 'aurelia-pal';
4 |
5 | var CompileSpy = (function () {
6 | function CompileSpy(element, instruction) {
7 | getLogger('compile-spy').info(element.toString(), instruction);
8 | }
9 | Object.defineProperty(CompileSpy, "inject", {
10 | get: function () { return [DOM.Element, TargetInstruction]; },
11 | enumerable: false,
12 | configurable: true
13 | });
14 | CompileSpy.$resource = {
15 | type: 'attribute',
16 | name: 'compile-spy'
17 | };
18 | return CompileSpy;
19 | }());
20 |
21 | var ViewSpy = (function () {
22 | function ViewSpy() {
23 | this.logger = getLogger('view-spy');
24 | }
25 | ViewSpy.prototype._log = function (lifecycleName, context) {
26 | if (!this.value && lifecycleName === 'created') {
27 | this.logger.info(lifecycleName, this.view);
28 | }
29 | else if (this.value && this.value.indexOf(lifecycleName) !== -1) {
30 | this.logger.info(lifecycleName, this.view, context);
31 | }
32 | };
33 | ViewSpy.prototype.created = function (view) {
34 | this.view = view;
35 | this._log('created');
36 | };
37 | ViewSpy.prototype.bind = function (bindingContext) {
38 | this._log('bind', bindingContext);
39 | };
40 | ViewSpy.prototype.attached = function () {
41 | this._log('attached');
42 | };
43 | ViewSpy.prototype.detached = function () {
44 | this._log('detached');
45 | };
46 | ViewSpy.prototype.unbind = function () {
47 | this._log('unbind');
48 | };
49 | ViewSpy.$resource = {
50 | type: 'attribute',
51 | name: 'view-spy'
52 | };
53 | return ViewSpy;
54 | }());
55 |
56 | /******************************************************************************
57 | Copyright (c) Microsoft Corporation.
58 |
59 | Permission to use, copy, modify, and/or distribute this software for any
60 | purpose with or without fee is hereby granted.
61 |
62 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
63 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
64 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
65 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
66 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
67 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
68 | PERFORMANCE OF THIS SOFTWARE.
69 | ***************************************************************************** */
70 |
71 | var __assign = function() {
72 | __assign = Object.assign || function __assign(t) {
73 | for (var s, i = 1, n = arguments.length; i < n; i++) {
74 | s = arguments[i];
75 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
76 | }
77 | return t;
78 | };
79 | return __assign.apply(this, arguments);
80 | };
81 |
82 | function waitFor(getter, options) {
83 | if (options === void 0) { options = { present: true, interval: 50, timeout: 5000 }; }
84 | var timedOut = false;
85 | options = __assign({ present: true, interval: 50, timeout: 5000 }, options);
86 | function wait() {
87 | var element = getter();
88 | var found = element !== null && (!(element instanceof NodeList) &&
89 | !element.jquery || element.length > 0);
90 | if (!options.present === !found || timedOut) {
91 | return Promise.resolve(element);
92 | }
93 | return new Promise(function (rs) { return setTimeout(rs, options.interval); }).then(wait);
94 | }
95 | return Promise.race([
96 | new Promise(function (_, rj) { return setTimeout(function () {
97 | timedOut = true;
98 | rj(new Error(options.present ? 'Element not found' : 'Element not removed'));
99 | }, options.timeout); }),
100 | wait()
101 | ]);
102 | }
103 | function waitForDocumentElement(selector, options) {
104 | return waitFor(function () { return document.querySelector(selector); }, options);
105 | }
106 | function waitForDocumentElements(selector, options) {
107 | return waitFor(function () { return document.querySelectorAll(selector); }, options);
108 | }
109 |
110 | var StageComponent = (function () {
111 | function StageComponent() {
112 | }
113 | StageComponent.withResources = function (resources) {
114 | if (resources === void 0) { resources = []; }
115 | return new ComponentTester().withResources(resources);
116 | };
117 | return StageComponent;
118 | }());
119 | var ComponentTester = (function () {
120 | function ComponentTester() {
121 | this.resources = [];
122 | }
123 | ComponentTester.prototype.configure = function (aurelia) {
124 | return aurelia.use.standardConfiguration();
125 | };
126 | ComponentTester.prototype.bootstrap = function (configure) {
127 | this.configure = configure;
128 | };
129 | ComponentTester.prototype.withResources = function (resources) {
130 | this.resources = resources;
131 | return this;
132 | };
133 | ComponentTester.prototype.inView = function (html) {
134 | this.html = html;
135 | return this;
136 | };
137 | ComponentTester.prototype.boundTo = function (bindingContext) {
138 | this.bindingContext = bindingContext;
139 | return this;
140 | };
141 | ComponentTester.prototype.manuallyHandleLifecycle = function () {
142 | this._prepareLifecycle();
143 | return this;
144 | };
145 | ComponentTester.prototype.create = function (bootstrap) {
146 | var _this = this;
147 | return bootstrap(function (aurelia) {
148 | return Promise.resolve(_this.configure(aurelia)).then(function () {
149 | if (_this.resources) {
150 | aurelia.use.globalResources(_this.resources);
151 | }
152 | return aurelia.start().then(function () {
153 | _this.host = document.createElement('div');
154 | _this.host.innerHTML = _this.html;
155 | document.body.appendChild(_this.host);
156 | return aurelia.enhance(_this.bindingContext, _this.host).then(function () {
157 | _this.rootView = aurelia.root;
158 | _this.element = _this.host.firstElementChild;
159 | if (aurelia.root.controllers.length) {
160 | _this.viewModel = aurelia.root.controllers[0].viewModel;
161 | }
162 | return new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, 0); });
163 | });
164 | });
165 | });
166 | });
167 | };
168 | ComponentTester.prototype.dispose = function () {
169 | if (this.host === undefined || this.rootView === undefined) {
170 | throw new Error('Cannot call ComponentTester.dispose() before ComponentTester.create()');
171 | }
172 | this.rootView.detached();
173 | this.rootView.unbind();
174 | return this.host.parentNode.removeChild(this.host);
175 | };
176 | ComponentTester.prototype._prepareLifecycle = function () {
177 | var _this = this;
178 | var bindPrototype = View.prototype.bind;
179 | View.prototype.bind = function () { };
180 | this.bind = function (bindingContext) { return new Promise(function (resolve) {
181 | View.prototype.bind = bindPrototype;
182 | if (bindingContext !== undefined) {
183 | _this.bindingContext = bindingContext;
184 | }
185 | _this.rootView.bind(_this.bindingContext);
186 | setTimeout(function () { return resolve(); }, 0);
187 | }); };
188 | var attachedPrototype = View.prototype.attached;
189 | View.prototype.attached = function () { };
190 | this.attached = function () { return new Promise(function (resolve) {
191 | View.prototype.attached = attachedPrototype;
192 | _this.rootView.attached();
193 | setTimeout(function () { return resolve(); }, 0);
194 | }); };
195 | this.detached = function () { return new Promise(function (resolve) {
196 | _this.rootView.detached();
197 | setTimeout(function () { return resolve(); }, 0);
198 | }); };
199 | this.unbind = function () { return new Promise(function (resolve) {
200 | _this.rootView.unbind();
201 | setTimeout(function () { return resolve(); }, 0);
202 | }); };
203 | };
204 | ComponentTester.prototype.waitForElement = function (selector, options) {
205 | var _this = this;
206 | return waitFor(function () { return _this.element.querySelector(selector); }, options);
207 | };
208 | ComponentTester.prototype.waitForElements = function (selector, options) {
209 | var _this = this;
210 | return waitFor(function () { return _this.element.querySelectorAll(selector); }, options);
211 | };
212 | return ComponentTester;
213 | }());
214 |
215 | function configure(config) {
216 | config.globalResources([CompileSpy, ViewSpy]);
217 | }
218 |
219 | export { CompileSpy, ComponentTester, StageComponent, ViewSpy, configure, waitFor, waitForDocumentElement, waitForDocumentElements };
220 | //# sourceMappingURL=aurelia-testing.js.map
221 |
--------------------------------------------------------------------------------
/dist/native-modules/aurelia-testing.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"aurelia-testing.js","sources":["../../src/compile-spy.ts","../../src/view-spy.ts","../../node_modules/tslib/tslib.es6.js","../../src/wait.ts","../../src/component-tester.ts","../../src/aurelia-testing.ts"],"sourcesContent":["import { type IStaticResourceConfig, TargetInstruction } from 'aurelia-templating';\r\nimport { getLogger } from 'aurelia-logging';\r\nimport { DOM } from 'aurelia-pal';\r\n\r\n/**\r\n * Attribute to be placed on any element to have it emit the View Compiler's\r\n * TargetInstruction into the debug console, giving you insight into all the\r\n * parsed bindings, behaviors and event handers for the targeted element.\r\n */\r\nexport class CompileSpy {\r\n /** @internal */\r\n static get inject() { return [DOM.Element, TargetInstruction]; }\r\n /** @internal */\r\n static $resource: IStaticResourceConfig = {\r\n type: 'attribute',\r\n name: 'compile-spy'\r\n }\r\n /**\r\n * Creates and instanse of CompileSpy.\r\n * @param element target element on where attribute is placed on.\r\n * @param instruction instructions for how the target element should be enhanced.\r\n */\r\n constructor(element: Element, instruction: TargetInstruction) {\r\n getLogger('compile-spy').info(element.toString(), instruction);\r\n }\r\n}\r\n","import { IStaticResourceConfig } from 'aurelia-templating';\r\nimport { getLogger, Logger } from 'aurelia-logging';\r\n\r\n/**\r\n * Attribute to be placed on any HTML element in a view to emit the View instance\r\n * to the debug console, giving you insight into the live View instance, including\r\n * all child views, live bindings, behaviors and more.\r\n */\r\nexport class ViewSpy {\r\n static $resource: IStaticResourceConfig = {\r\n type: 'attribute',\r\n name: 'view-spy'\r\n };\r\n\r\n private logger: Logger;\r\n private value: any;\r\n private view: any;\r\n\r\n /**\r\n * Creates a new instance of ViewSpy.\r\n */\r\n constructor() {\r\n this.logger = getLogger('view-spy');\r\n }\r\n\r\n private _log(lifecycleName: string, context?: {}) {\r\n if (!this.value && lifecycleName === 'created') {\r\n this.logger.info(lifecycleName, this.view);\r\n } else if (this.value && this.value.indexOf(lifecycleName) !== -1) {\r\n this.logger.info(lifecycleName, this.view, context);\r\n }\r\n }\r\n\r\n /**\r\n * Invoked when the target view is created.\r\n * @param view The target view.\r\n */\r\n public created(view: any) {\r\n this.view = view;\r\n this._log('created');\r\n }\r\n\r\n /**\r\n * Invoked when the target view is bound.\r\n * @param bindingContext The target view's binding context.\r\n */\r\n public bind(bindingContext: {}) {\r\n this._log('bind', bindingContext);\r\n }\r\n\r\n /**\r\n * Invoked when the target element is attached to the DOM.\r\n */\r\n public attached() {\r\n this._log('attached');\r\n }\r\n\r\n /**\r\n * Invoked when the target element is detached from the DOM.\r\n */\r\n public detached() {\r\n this._log('detached');\r\n }\r\n\r\n /**\r\n * Invoked when the target element is unbound.\r\n */\r\n public unbind() {\r\n this._log('unbind');\r\n }\r\n}\r\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/**\r\n * Generic function to wait for something to happen. Uses polling\r\n * @param getter: a getter function that returns anything else than `null` or an\r\n * empty array or an empty jQuery object when the\r\n * condition is met\r\n * @param options: lookup options, defaults to\r\n * `{present: true, interval: 50, timeout: 5000}`\r\n */\r\nexport function waitFor(getter: () => T, options: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n} = {present: true, interval: 50, timeout: 5000}): Promise {\r\n // prevents infinite recursion if the request times out\r\n let timedOut = false;\r\n\r\n options = {\r\n present: true,\r\n interval: 50,\r\n timeout: 5000,\r\n ...options\r\n };\r\n\r\n function wait(): Promise {\r\n const element = getter();\r\n // boolean is needed here, hence the length > 0\r\n const found = element !== null && (!(element instanceof NodeList) &&\r\n !(element as any).jquery || (element as any).length > 0);\r\n\r\n if (!options.present === !found || timedOut) {\r\n return Promise.resolve(element);\r\n }\r\n\r\n return new Promise(rs => setTimeout(rs, options.interval)).then(wait);\r\n }\r\n\r\n return Promise.race([\r\n new Promise(\r\n (_, rj) => setTimeout(() => {\r\n timedOut = true;\r\n rj(new Error(options.present ? 'Element not found' : 'Element not removed'));\r\n }, options.timeout)\r\n ),\r\n wait()\r\n ]) as Promise;\r\n}\r\n\r\nexport function waitForDocumentElement(selector: string, options?: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n}): Promise {\r\n return waitFor(() => document.querySelector(selector) as Element, options);\r\n}\r\n\r\nexport function waitForDocumentElements(selector: string, options?: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n}): Promise> {\r\n return waitFor(() => document.querySelectorAll(selector), options);\r\n}\r\n","import { View } from 'aurelia-templating';\r\nimport type { Aurelia, FrameworkConfiguration } from 'aurelia-framework';\r\nimport { waitFor } from './wait';\r\n\r\ninterface AureliaWithRoot extends Aurelia {\r\n root: ViewWithControllers;\r\n}\r\n\r\ninterface ViewWithControllers extends View {\r\n controllers: {viewModel: any}[];\r\n}\r\n\r\nexport class StageComponent {\r\n public static withResources(resources: string | string[] = []): ComponentTester {\r\n return new ComponentTester().withResources(resources);\r\n }\r\n}\r\n\r\nexport class ComponentTester {\r\n public bind: (bindingContext: {}) => Promise;\r\n public attached: () => Promise;\r\n public detached: () => Promise;\r\n public unbind: () => Promise;\r\n public element: Element;\r\n public viewModel: T;\r\n\r\n private html: string;\r\n private resources: string | Function | (string | Function)[] = [];\r\n private bindingContext: {};\r\n private rootView: View;\r\n private host: HTMLDivElement;\r\n\r\n public configure(aurelia: Aurelia): FrameworkConfiguration {\r\n return aurelia.use.standardConfiguration();\r\n }\r\n\r\n public bootstrap(configure: (aurelia: Aurelia) => FrameworkConfiguration) {\r\n this.configure = configure;\r\n }\r\n\r\n public withResources(resources: string | string[]): this {\r\n this.resources = resources;\r\n return this;\r\n }\r\n\r\n public inView(html: string): this {\r\n this.html = html;\r\n return this;\r\n }\r\n\r\n public boundTo(bindingContext: {}): this {\r\n this.bindingContext = bindingContext;\r\n return this;\r\n }\r\n\r\n public manuallyHandleLifecycle(): this {\r\n this._prepareLifecycle();\r\n return this;\r\n }\r\n\r\n public create(bootstrap: (configure: (aurelia: Aurelia) => Promise) => Promise): Promise {\r\n return bootstrap((aurelia: AureliaWithRoot) => {\r\n return Promise.resolve(this.configure(aurelia)).then(() => {\r\n if (this.resources) {\r\n aurelia.use.globalResources(this.resources);\r\n }\r\n\r\n return aurelia.start().then(() => {\r\n this.host = document.createElement('div');\r\n this.host.innerHTML = this.html;\r\n\r\n document.body.appendChild(this.host);\r\n\r\n return aurelia.enhance(this.bindingContext, this.host).then(() => {\r\n this.rootView = aurelia.root;\r\n this.element = this.host.firstElementChild as Element;\r\n\r\n if (aurelia.root.controllers.length) {\r\n this.viewModel = aurelia.root.controllers[0].viewModel;\r\n }\r\n\r\n return new Promise(resolve => setTimeout(() => resolve(), 0)) as Promise;\r\n });\r\n });\r\n });\r\n });\r\n }\r\n\r\n public dispose(): Element {\r\n if (this.host === undefined || this.rootView === undefined) {\r\n throw new Error(\r\n 'Cannot call ComponentTester.dispose() before ComponentTester.create()'\r\n );\r\n }\r\n\r\n this.rootView.detached();\r\n this.rootView.unbind();\r\n\r\n return (this.host.parentNode as Node).removeChild(this.host);\r\n }\r\n\r\n private _prepareLifecycle() {\r\n // bind\r\n const bindPrototype = View.prototype.bind;\r\n // tslint:disable-next-line:no-empty\r\n View.prototype.bind = () => {};\r\n this.bind = bindingContext => new Promise(resolve => {\r\n View.prototype.bind = bindPrototype;\r\n if (bindingContext !== undefined) {\r\n this.bindingContext = bindingContext;\r\n }\r\n this.rootView.bind(this.bindingContext);\r\n setTimeout(() => resolve(), 0);\r\n });\r\n\r\n // attached\r\n const attachedPrototype = View.prototype.attached;\r\n // tslint:disable-next-line:no-empty\r\n View.prototype.attached = () => {};\r\n this.attached = () => new Promise(resolve => {\r\n View.prototype.attached = attachedPrototype;\r\n this.rootView.attached();\r\n setTimeout(() => resolve(), 0);\r\n });\r\n\r\n // detached\r\n this.detached = () => new Promise(resolve => {\r\n this.rootView.detached();\r\n setTimeout(() => resolve(), 0);\r\n });\r\n\r\n // unbind\r\n this.unbind = () => new Promise(resolve => {\r\n this.rootView.unbind();\r\n setTimeout(() => resolve(), 0);\r\n });\r\n }\r\n\r\n public waitForElement(selector: string, options?: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n }): Promise {\r\n return waitFor(() => this.element.querySelector(selector) as Element, options);\r\n }\r\n\r\n public waitForElements(selector: string, options?: {\r\n present?: boolean,\r\n interval?: number,\r\n timeout?: number\r\n }): Promise> {\r\n return waitFor(() => this.element.querySelectorAll(selector) as NodeListOf, options);\r\n }\r\n}\r\n","import type { FrameworkConfiguration } from 'aurelia-framework';\r\nimport { CompileSpy } from './compile-spy';\r\nimport { ViewSpy } from './view-spy';\r\n\r\nexport * from './compile-spy';\r\nexport * from './view-spy';\r\nexport * from './component-tester';\r\nexport * from './wait';\r\n\r\nexport function configure(config: FrameworkConfiguration) {\r\n config.globalResources([CompileSpy, ViewSpy]);\r\n}\r\n"],"names":[],"mappings":";;;;AASA,IAAA,UAAA,IAAA,YAAA;IAaE,SAAY,UAAA,CAAA,OAAgB,EAAE,WAA8B,EAAA;AAC1D,QAAA,SAAS,CAAC,aAAa,CAAC,CAAC,IA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,EAAA,OAAA,OAAO,EAAE,GAAA,EAAE,CAAC,CAAC,CAAC;SAChC,CAAC,CAHoB,EAGpB,CAAC;QAGH,IAAI,CAAC,MAAM,GAAG,YAAA,EAAM,OAAA,IAAI,OAAO,CAAC,UAAA,OAAO,EAAA;AACrC,YAAA,KAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YACvB,UAAU,CAAC,YAAM,EAAA,OAAA,OAAO,EAAE,GAAA,EAAE,CAAC,CAAC,CAAC;SAChC,CAAC,CAHkB,EAGlB,CAAC;KACJ,CAAA;AAEM,IAAA,eAAA,CAAA,SAAA,CAAA,cAAc,GAArB,UAAsB,QAAgB,EAAE,OAIvC,EAAA;QAJD,IAMC,KAAA,GAAA,IAAA,CAAA;AADC,QAAA,OAAO,OAAO,CAAC,YAAA,EAAM,OAAA,KAAI,CAAC,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAY,CAAA,EAAA,EAAE,OAAO,CAAC,CAAC;KAChF,CAAA;AAEM,IAAA,eAAA,CAAA,SAAA,CAAA,eAAe,GAAtB,UAAuB,QAAgB,EAAE,OAIxC,EAAA;QAJD,IAMC,KAAA,GAAA,IAAA,CAAA;AADC,QAAA,OAAO,OAAO,CAAC,YAAA,EAAM,OAAA,KAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAwB,CAAA,EAAA,EAAE,OAAO,CAAC,CAAC;KAC/F,CAAA;IACH,OAAC,eAAA,CAAA;AAAD,CAAC,EAAA;;AChJK,SAAU,SAAS,CAAC,MAA8B,EAAA;IACtD,MAAM,CAAC,eAAe,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;AAChD;;;;"}
--------------------------------------------------------------------------------
/dist/system/aurelia-testing.js:
--------------------------------------------------------------------------------
1 | System.register(['aurelia-templating', 'aurelia-logging', 'aurelia-pal'], (function (exports) {
2 | 'use strict';
3 | var TargetInstruction, View, getLogger, DOM;
4 | return {
5 | setters: [function (module) {
6 | TargetInstruction = module.TargetInstruction;
7 | View = module.View;
8 | }, function (module) {
9 | getLogger = module.getLogger;
10 | }, function (module) {
11 | DOM = module.DOM;
12 | }],
13 | execute: (function () {
14 |
15 | exports({
16 | configure: configure,
17 | waitFor: waitFor,
18 | waitForDocumentElement: waitForDocumentElement,
19 | waitForDocumentElements: waitForDocumentElements
20 | });
21 |
22 | var CompileSpy = exports('CompileSpy', (function () {
23 | function CompileSpy(element, instruction) {
24 | getLogger('compile-spy').info(element.toString(), instruction);
25 | }
26 | Object.defineProperty(CompileSpy, "inject", {
27 | get: function () { return [DOM.Element, TargetInstruction]; },
28 | enumerable: false,
29 | configurable: true
30 | });
31 | CompileSpy.$resource = {
32 | type: 'attribute',
33 | name: 'compile-spy'
34 | };
35 | return CompileSpy;
36 | }()));
37 |
38 | var ViewSpy = exports('ViewSpy', (function () {
39 | function ViewSpy() {
40 | this.logger = getLogger('view-spy');
41 | }
42 | ViewSpy.prototype._log = function (lifecycleName, context) {
43 | if (!this.value && lifecycleName === 'created') {
44 | this.logger.info(lifecycleName, this.view);
45 | }
46 | else if (this.value && this.value.indexOf(lifecycleName) !== -1) {
47 | this.logger.info(lifecycleName, this.view, context);
48 | }
49 | };
50 | ViewSpy.prototype.created = function (view) {
51 | this.view = view;
52 | this._log('created');
53 | };
54 | ViewSpy.prototype.bind = function (bindingContext) {
55 | this._log('bind', bindingContext);
56 | };
57 | ViewSpy.prototype.attached = function () {
58 | this._log('attached');
59 | };
60 | ViewSpy.prototype.detached = function () {
61 | this._log('detached');
62 | };
63 | ViewSpy.prototype.unbind = function () {
64 | this._log('unbind');
65 | };
66 | ViewSpy.$resource = {
67 | type: 'attribute',
68 | name: 'view-spy'
69 | };
70 | return ViewSpy;
71 | }()));
72 |
73 | /******************************************************************************
74 | Copyright (c) Microsoft Corporation.
75 |
76 | Permission to use, copy, modify, and/or distribute this software for any
77 | purpose with or without fee is hereby granted.
78 |
79 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
80 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
81 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
82 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
83 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
84 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
85 | PERFORMANCE OF THIS SOFTWARE.
86 | ***************************************************************************** */
87 |
88 | var __assign = function() {
89 | __assign = Object.assign || function __assign(t) {
90 | for (var s, i = 1, n = arguments.length; i < n; i++) {
91 | s = arguments[i];
92 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
93 | }
94 | return t;
95 | };
96 | return __assign.apply(this, arguments);
97 | };
98 |
99 | function waitFor(getter, options) {
100 | if (options === void 0) { options = { present: true, interval: 50, timeout: 5000 }; }
101 | var timedOut = false;
102 | options = __assign({ present: true, interval: 50, timeout: 5000 }, options);
103 | function wait() {
104 | var element = getter();
105 | var found = element !== null && (!(element instanceof NodeList) &&
106 | !element.jquery || element.length > 0);
107 | if (!options.present === !found || timedOut) {
108 | return Promise.resolve(element);
109 | }
110 | return new Promise(function (rs) { return setTimeout(rs, options.interval); }).then(wait);
111 | }
112 | return Promise.race([
113 | new Promise(function (_, rj) { return setTimeout(function () {
114 | timedOut = true;
115 | rj(new Error(options.present ? 'Element not found' : 'Element not removed'));
116 | }, options.timeout); }),
117 | wait()
118 | ]);
119 | }
120 | function waitForDocumentElement(selector, options) {
121 | return waitFor(function () { return document.querySelector(selector); }, options);
122 | }
123 | function waitForDocumentElements(selector, options) {
124 | return waitFor(function () { return document.querySelectorAll(selector); }, options);
125 | }
126 |
127 | var StageComponent = exports('StageComponent', (function () {
128 | function StageComponent() {
129 | }
130 | StageComponent.withResources = function (resources) {
131 | if (resources === void 0) { resources = []; }
132 | return new ComponentTester().withResources(resources);
133 | };
134 | return StageComponent;
135 | }()));
136 | var ComponentTester = exports('ComponentTester', (function () {
137 | function ComponentTester() {
138 | this.resources = [];
139 | }
140 | ComponentTester.prototype.configure = function (aurelia) {
141 | return aurelia.use.standardConfiguration();
142 | };
143 | ComponentTester.prototype.bootstrap = function (configure) {
144 | this.configure = configure;
145 | };
146 | ComponentTester.prototype.withResources = function (resources) {
147 | this.resources = resources;
148 | return this;
149 | };
150 | ComponentTester.prototype.inView = function (html) {
151 | this.html = html;
152 | return this;
153 | };
154 | ComponentTester.prototype.boundTo = function (bindingContext) {
155 | this.bindingContext = bindingContext;
156 | return this;
157 | };
158 | ComponentTester.prototype.manuallyHandleLifecycle = function () {
159 | this._prepareLifecycle();
160 | return this;
161 | };
162 | ComponentTester.prototype.create = function (bootstrap) {
163 | var _this = this;
164 | return bootstrap(function (aurelia) {
165 | return Promise.resolve(_this.configure(aurelia)).then(function () {
166 | if (_this.resources) {
167 | aurelia.use.globalResources(_this.resources);
168 | }
169 | return aurelia.start().then(function () {
170 | _this.host = document.createElement('div');
171 | _this.host.innerHTML = _this.html;
172 | document.body.appendChild(_this.host);
173 | return aurelia.enhance(_this.bindingContext, _this.host).then(function () {
174 | _this.rootView = aurelia.root;
175 | _this.element = _this.host.firstElementChild;
176 | if (aurelia.root.controllers.length) {
177 | _this.viewModel = aurelia.root.controllers[0].viewModel;
178 | }
179 | return new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, 0); });
180 | });
181 | });
182 | });
183 | });
184 | };
185 | ComponentTester.prototype.dispose = function () {
186 | if (this.host === undefined || this.rootView === undefined) {
187 | throw new Error('Cannot call ComponentTester.dispose() before ComponentTester.create()');
188 | }
189 | this.rootView.detached();
190 | this.rootView.unbind();
191 | return this.host.parentNode.removeChild(this.host);
192 | };
193 | ComponentTester.prototype._prepareLifecycle = function () {
194 | var _this = this;
195 | var bindPrototype = View.prototype.bind;
196 | View.prototype.bind = function () { };
197 | this.bind = function (bindingContext) { return new Promise(function (resolve) {
198 | View.prototype.bind = bindPrototype;
199 | if (bindingContext !== undefined) {
200 | _this.bindingContext = bindingContext;
201 | }
202 | _this.rootView.bind(_this.bindingContext);
203 | setTimeout(function () { return resolve(); }, 0);
204 | }); };
205 | var attachedPrototype = View.prototype.attached;
206 | View.prototype.attached = function () { };
207 | this.attached = function () { return new Promise(function (resolve) {
208 | View.prototype.attached = attachedPrototype;
209 | _this.rootView.attached();
210 | setTimeout(function () { return resolve(); }, 0);
211 | }); };
212 | this.detached = function () { return new Promise(function (resolve) {
213 | _this.rootView.detached();
214 | setTimeout(function () { return resolve(); }, 0);
215 | }); };
216 | this.unbind = function () { return new Promise(function (resolve) {
217 | _this.rootView.unbind();
218 | setTimeout(function () { return resolve(); }, 0);
219 | }); };
220 | };
221 | ComponentTester.prototype.waitForElement = function (selector, options) {
222 | var _this = this;
223 | return waitFor(function () { return _this.element.querySelector(selector); }, options);
224 | };
225 | ComponentTester.prototype.waitForElements = function (selector, options) {
226 | var _this = this;
227 | return waitFor(function () { return _this.element.querySelectorAll(selector); }, options);
228 | };
229 | return ComponentTester;
230 | }()));
231 |
232 | function configure(config) {
233 | config.globalResources([CompileSpy, ViewSpy]);
234 | }
235 |
236 | })
237 | };
238 | }));
239 | //# sourceMappingURL=aurelia-testing.js.map
240 |
--------------------------------------------------------------------------------
/dist/types/aurelia-testing.d.ts:
--------------------------------------------------------------------------------
1 | // Generated by dts-bundle-generator v6.9.0
2 |
3 | import { Aurelia, FrameworkConfiguration } from 'aurelia-framework';
4 | import { IStaticResourceConfig, TargetInstruction } from 'aurelia-templating';
5 |
6 | /**
7 | * Attribute to be placed on any element to have it emit the View Compiler's
8 | * TargetInstruction into the debug console, giving you insight into all the
9 | * parsed bindings, behaviors and event handers for the targeted element.
10 | */
11 | export declare class CompileSpy {
12 | /**
13 | * Creates and instanse of CompileSpy.
14 | * @param element target element on where attribute is placed on.
15 | * @param instruction instructions for how the target element should be enhanced.
16 | */
17 | constructor(element: Element, instruction: TargetInstruction);
18 | }
19 | /**
20 | * Attribute to be placed on any HTML element in a view to emit the View instance
21 | * to the debug console, giving you insight into the live View instance, including
22 | * all child views, live bindings, behaviors and more.
23 | */
24 | export declare class ViewSpy {
25 | static $resource: IStaticResourceConfig;
26 | private logger;
27 | private value;
28 | private view;
29 | /**
30 | * Creates a new instance of ViewSpy.
31 | */
32 | constructor();
33 | private _log;
34 | /**
35 | * Invoked when the target view is created.
36 | * @param view The target view.
37 | */
38 | created(view: any): void;
39 | /**
40 | * Invoked when the target view is bound.
41 | * @param bindingContext The target view's binding context.
42 | */
43 | bind(bindingContext: {}): void;
44 | /**
45 | * Invoked when the target element is attached to the DOM.
46 | */
47 | attached(): void;
48 | /**
49 | * Invoked when the target element is detached from the DOM.
50 | */
51 | detached(): void;
52 | /**
53 | * Invoked when the target element is unbound.
54 | */
55 | unbind(): void;
56 | }
57 | export declare class StageComponent {
58 | static withResources(resources?: string | string[]): ComponentTester;
59 | }
60 | export declare class ComponentTester {
61 | bind: (bindingContext: {}) => Promise;
62 | attached: () => Promise;
63 | detached: () => Promise;
64 | unbind: () => Promise;
65 | element: Element;
66 | viewModel: T;
67 | private html;
68 | private resources;
69 | private bindingContext;
70 | private rootView;
71 | private host;
72 | configure(aurelia: Aurelia): FrameworkConfiguration;
73 | bootstrap(configure: (aurelia: Aurelia) => FrameworkConfiguration): void;
74 | withResources(resources: string | string[]): this;
75 | inView(html: string): this;
76 | boundTo(bindingContext: {}): this;
77 | manuallyHandleLifecycle(): this;
78 | create(bootstrap: (configure: (aurelia: Aurelia) => Promise) => Promise): Promise;
79 | dispose(): Element;
80 | private _prepareLifecycle;
81 | waitForElement(selector: string, options?: {
82 | present?: boolean;
83 | interval?: number;
84 | timeout?: number;
85 | }): Promise;
86 | waitForElements(selector: string, options?: {
87 | present?: boolean;
88 | interval?: number;
89 | timeout?: number;
90 | }): Promise>;
91 | }
92 | /**
93 | * Generic function to wait for something to happen. Uses polling
94 | * @param getter: a getter function that returns anything else than `null` or an
95 | * empty array or an empty jQuery object when the
96 | * condition is met
97 | * @param options: lookup options, defaults to
98 | * `{present: true, interval: 50, timeout: 5000}`
99 | */
100 | export declare function waitFor(getter: () => T, options?: {
101 | present?: boolean;
102 | interval?: number;
103 | timeout?: number;
104 | }): Promise;
105 | export declare function waitForDocumentElement(selector: string, options?: {
106 | present?: boolean;
107 | interval?: number;
108 | timeout?: number;
109 | }): Promise;
110 | export declare function waitForDocumentElements(selector: string, options?: {
111 | present?: boolean;
112 | interval?: number;
113 | timeout?: number;
114 | }): Promise>;
115 | export declare function configure(config: FrameworkConfiguration): void;
116 |
117 | export {};
118 |
--------------------------------------------------------------------------------
/doc/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4 |
5 | ## [1.1.0](https://github.com/aurelia/testing/compare/1.0.0...1.1.0) (2022-05-07)
6 |
7 |
8 | ### Features
9 |
10 | * **component-tester:** allow using class in withResources ([#100](https://github.com/aurelia/testing/issues/100)) ([3b71fbc](https://github.com/aurelia/testing/commit/3b71fbc9b74a3ed2b6b0f23c35bccb875cee804e))
11 | * **component-tester:** use `this` type in return type to enable better extension ([#97](https://github.com/aurelia/testing/issues/97))
12 |
13 | ### Bug Fixes
14 |
15 | * Resolve security dependency issues
16 |
17 |
18 |
19 | # [1.0.0](https://github.com/aurelia/testing/compare/1.0.0-beta.4.0.0...1.0.0) (2018-09-25)
20 |
21 |
22 | ### Bug Fixes
23 |
24 | * **code example:** fix to the manually handling lifecycle example ([#82](https://github.com/aurelia/testing/issues/82)) ([b0fb939](https://github.com/aurelia/testing/commit/b0fb939))
25 | * **waitFor:** reject with Error rather than string ([#84](https://github.com/aurelia/testing/issues/84)) ([054dab5](https://github.com/aurelia/testing/commit/054dab5))
26 |
27 |
28 |
29 |
30 | # [1.0.0-beta.4.0.0](https://github.com/aurelia/testing/compare/1.0.0-beta.3.0.1...1.0.0-beta.4.0.0) (2017-11-06)
31 |
32 | This entire library was converted to TypeScript. This doesn't involve any breaking changes to the functionality, but the TypeScript definitions are now more accurate and could result in some requried code fixups for TS consumers.
33 |
34 |
35 | # [1.0.0-beta.3.0.1](https://github.com/aurelia/testing/compare/1.0.0-beta.3.0.0...v1.0.0-beta.3.0.1) (2017-03-25)
36 |
37 |
38 | ### Bug Fixes
39 |
40 | * **ComponentTester:** import missing waitFor function ([#60](https://github.com/aurelia/testing/issues/60)) ([1ecfbfe](https://github.com/aurelia/testing/commit/1ecfbfe))
41 | * **ComponentTester:** withResources args are optional ([2154b8f](https://github.com/aurelia/testing/commit/2154b8f))
42 |
43 |
44 |
45 |
46 | # [1.0.0-beta.3.0.0](https://github.com/aurelia/testing/compare/1.0.0-beta.2.0.1...v1.0.0-beta.3.0.0) (2017-03-03)
47 |
48 |
49 | ### Bug Fixes
50 |
51 | * **typings:** Typings for StageComponent ([#52](https://github.com/aurelia/testing/issues/52)) ([01036e7](https://github.com/aurelia/testing/commit/01036e7)), closes [#46](https://github.com/aurelia/testing/issues/46)
52 |
53 |
54 | ### Features
55 |
56 | * **component-tester:** add waitForElement method and options ([#32](https://github.com/aurelia/testing/issues/32)) ([65eb382](https://github.com/aurelia/testing/commit/65eb382))
57 |
58 |
59 |
60 |
61 | # [1.0.0-beta.2.0.0](https://github.com/aurelia/testing/compare/1.0.0-beta.1.0.3...v1.0.0-beta.2.0.0) (2016-07-27)
62 |
63 |
64 | ### Bug Fixes
65 |
66 | * **component-tester:** call detached and unbind when disposing of tested component ([#27](https://github.com/aurelia/testing/issues/27)) ([f1585cc](https://github.com/aurelia/testing/commit/f1585cc))
67 | * **component-tester:** handle enhance promise ([681cff2](https://github.com/aurelia/testing/commit/681cff2))
68 |
69 |
70 |
71 |
72 | # [1.0.0-beta.1.0.0](https://github.com/aurelia/testing/compare/0.5.0...v1.0.0-beta.1.0.0) (2016-06-22)
73 |
74 |
75 |
76 |
77 | # [0.5.0](https://github.com/aurelia/testing/compare/0.4.2...v0.5.0) (2016-06-22)
78 |
79 |
80 | ### Features
81 |
82 | * **component-tester:** remove hard dependency on bootstrapper ([3887d19](https://github.com/aurelia/testing/commit/3887d19))
83 |
84 |
85 |
86 | ### 0.3.1 (2016-06-08)
87 |
88 |
89 | #### Bug Fixes
90 |
91 | * **aurelia-testing:** missing exports ([94bfbaca](http://github.com/aurelia/testing/commit/94bfbacac394d10a35da19adf044612f89066a39), closes [#10](http://github.com/aurelia/testing/issues/10))
92 |
93 |
94 | ## 0.3.0 (2016-05-31)
95 |
96 |
97 | #### Bug Fixes
98 |
99 | * **index:** correct export strategy ([d1a0533f](http://github.com/aurelia/testing/commit/d1a0533f5a462f5df8f711798aab7a9b1ec95bdd))
100 | * **package:** add missing dependencies ([466971e9](http://github.com/aurelia/testing/commit/466971e9d5564756b2bbd7c22415de83e6e2b9cc))
101 |
102 |
103 | #### Features
104 |
105 | * **spies:** add view-spy and compile-spy ([fc81850f](http://github.com/aurelia/testing/commit/fc81850f9f23a2131fc370d0b744f53ddb58374e))
106 |
107 |
108 | ### 0.2.2 (2016-05-17)
109 |
110 |
111 | #### Features
112 |
113 | * **component-tester:** make configure function public ([b17e4ac0](http://github.com/aurelia/testing/commit/b17e4ac0e6dac2af8fb0ef75261677744982ee99))
114 |
115 |
116 | ### 0.2.1 (2016-05-10)
117 |
118 |
119 | ## 0.2.0 (2016-05-03)
120 |
121 |
122 | #### Bug Fixes
123 |
124 | * **component-tester:** correct type annotations ([53f57f08](http://github.com/aurelia/testing/commit/53f57f080c22015a720f58cf9493d1c14cbfd3ef))
125 |
126 |
127 | #### Features
128 |
129 | * **component-tester:**
130 | * support lifecycle testing ([cd9bd78a](http://github.com/aurelia/testing/commit/cd9bd78a0905c0e4900a6f4fbc67ef1e30990075))
131 | * enable custom bootstrap ([50d1d72a](http://github.com/aurelia/testing/commit/50d1d72aa5af9ed5e8fd20efdf7fade027baccb2))
132 | * initial poc ([1db19514](http://github.com/aurelia/testing/commit/1db195142715503746e49e179c044c0ad39a4763))
133 |
--------------------------------------------------------------------------------
/doc/MAINTAINER.md:
--------------------------------------------------------------------------------
1 | ## Workflow releasing a new version
2 |
3 | 1. Update: pull latest master with `git checkout master && git pull`
4 | 2. Cut release: Run `npm run cut-release`. Example:
5 |
6 | ```shell
7 | # automatic versioning
8 | npm run cut-release
9 | # manual versioning
10 | npm run cut-release -- -- --release-as minor
11 | npm run cut-release -- -- --release-as 1.0.1-beta.1
12 | ```
13 | 3. Commit: `git add .` and then `git commit chore(release): prepare release XXX` where `XXX` is the new version
14 | 4. Tag: `git tag -a XXX` where `XXX` is the version
15 | 5. Push to remote repo: `git push --follow-tags`
16 | 6. Publish: Run `npm publish` to release the new version
17 |
--------------------------------------------------------------------------------
/doc/api.json:
--------------------------------------------------------------------------------
1 | {"id":0,"name":"aurelia-testing","kind":1,"kindString":"Project","flags":{},"originalName":"","children":[{"id":4,"name":"CompileSpy","kind":128,"kindString":"Class","flags":{},"comment":{"shortText":"Attribute to be placed on any element to have it emit the View Compiler's\nTargetInstruction into the debug console, giving you insight into all the\nparsed bindings, behaviors and event handers for the targeted element."},"children":[{"id":10,"name":"constructor","kind":512,"kindString":"Constructor","flags":{},"sources":[{"fileName":"src/compile-spy.ts","line":23,"character":2}],"signatures":[{"id":11,"name":"new CompileSpy","kind":16384,"kindString":"Constructor signature","flags":{},"comment":{"shortText":"Creates and instanse of CompileSpy."},"parameters":[{"id":12,"name":"element","kind":32768,"kindString":"Parameter","flags":{},"comment":{"shortText":"target element on where attribute is placed on."},"type":{"type":"reference","qualifiedName":"Element","package":"typescript","name":"Element"}},{"id":13,"name":"instruction","kind":32768,"kindString":"Parameter","flags":{},"comment":{"shortText":"instructions for how the target element should be enhanced.\n"},"type":{"type":"reference","qualifiedName":"TargetInstruction","package":"aurelia-templating","name":"TargetInstruction"}}],"type":{"type":"reference","id":4,"name":"CompileSpy"}}]}],"groups":[{"title":"Constructors","kind":512,"children":[10]}],"sources":[{"fileName":"src/compile-spy.ts","line":10,"character":13}]},{"id":46,"name":"ComponentTester","kind":128,"kindString":"Class","flags":{},"children":[{"id":47,"name":"constructor","kind":512,"kindString":"Constructor","flags":{},"signatures":[{"id":48,"name":"new ComponentTester","kind":16384,"kindString":"Constructor signature","flags":{},"typeParameter":[{"id":49,"name":"T","kind":131072,"kindString":"Type parameter","flags":{},"default":{"type":"intrinsic","name":"any"}}],"type":{"type":"reference","id":46,"typeArguments":[{"type":"reference","id":49,"name":"T"}],"name":"ComponentTester"}}]},{"id":55,"name":"attached","kind":1024,"kindString":"Property","flags":{"isPublic":true},"sources":[{"fileName":"src/component-tester.ts","line":21,"character":9}],"type":{"type":"reflection","declaration":{"id":56,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":57,"name":"__type","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"reference","typeArguments":[{"type":"intrinsic","name":"void"}],"qualifiedName":"Promise","package":"typescript","name":"Promise"}}]}}},{"id":50,"name":"bind","kind":1024,"kindString":"Property","flags":{"isPublic":true},"sources":[{"fileName":"src/component-tester.ts","line":20,"character":9}],"type":{"type":"reflection","declaration":{"id":51,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":52,"name":"__type","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":53,"name":"bindingContext","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":54,"name":"__type","kind":65536,"kindString":"Type literal","flags":{}}}}],"type":{"type":"reference","typeArguments":[{"type":"intrinsic","name":"void"}],"qualifiedName":"Promise","package":"typescript","name":"Promise"}}]}}},{"id":68,"name":"bindingContext","kind":1024,"kindString":"Property","flags":{"isPrivate":true},"sources":[{"fileName":"src/component-tester.ts","line":29,"character":10}],"type":{"type":"reflection","declaration":{"id":69,"name":"__type","kind":65536,"kindString":"Type literal","flags":{}}}},{"id":58,"name":"detached","kind":1024,"kindString":"Property","flags":{"isPublic":true},"sources":[{"fileName":"src/component-tester.ts","line":22,"character":9}],"type":{"type":"reflection","declaration":{"id":59,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":60,"name":"__type","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"reference","typeArguments":[{"type":"intrinsic","name":"void"}],"qualifiedName":"Promise","package":"typescript","name":"Promise"}}]}}},{"id":64,"name":"element","kind":1024,"kindString":"Property","flags":{"isPublic":true},"sources":[{"fileName":"src/component-tester.ts","line":24,"character":9}],"type":{"type":"reference","qualifiedName":"Element","package":"typescript","name":"Element"}},{"id":71,"name":"host","kind":1024,"kindString":"Property","flags":{"isPrivate":true},"sources":[{"fileName":"src/component-tester.ts","line":31,"character":10}],"type":{"type":"reference","qualifiedName":"HTMLDivElement","package":"typescript","name":"HTMLDivElement"}},{"id":66,"name":"html","kind":1024,"kindString":"Property","flags":{"isPrivate":true},"sources":[{"fileName":"src/component-tester.ts","line":27,"character":10}],"type":{"type":"intrinsic","name":"string"}},{"id":67,"name":"resources","kind":1024,"kindString":"Property","flags":{"isPrivate":true},"sources":[{"fileName":"src/component-tester.ts","line":28,"character":10}],"type":{"type":"union","types":[{"type":"intrinsic","name":"string"},{"type":"reference","qualifiedName":"Function","package":"typescript","name":"Function"},{"type":"array","elementType":{"type":"union","types":[{"type":"intrinsic","name":"string"},{"type":"reference","qualifiedName":"Function","package":"typescript","name":"Function"}]}}]},"defaultValue":"[]"},{"id":70,"name":"rootView","kind":1024,"kindString":"Property","flags":{"isPrivate":true},"sources":[{"fileName":"src/component-tester.ts","line":30,"character":10}],"type":{"type":"reference","qualifiedName":"View","package":"aurelia-templating","name":"View"}},{"id":61,"name":"unbind","kind":1024,"kindString":"Property","flags":{"isPublic":true},"sources":[{"fileName":"src/component-tester.ts","line":23,"character":9}],"type":{"type":"reflection","declaration":{"id":62,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":63,"name":"__type","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"reference","typeArguments":[{"type":"intrinsic","name":"void"}],"qualifiedName":"Promise","package":"typescript","name":"Promise"}}]}}},{"id":65,"name":"viewModel","kind":1024,"kindString":"Property","flags":{"isPublic":true},"sources":[{"fileName":"src/component-tester.ts","line":25,"character":9}],"type":{"type":"reference","id":49,"name":"T"}},{"id":104,"name":"_prepareLifecycle","kind":2048,"kindString":"Method","flags":{"isPrivate":true},"sources":[{"fileName":"src/component-tester.ts","line":102,"character":10}],"signatures":[{"id":105,"name":"_prepareLifecycle","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"intrinsic","name":"void"}}]},{"id":75,"name":"bootstrap","kind":2048,"kindString":"Method","flags":{"isPublic":true},"sources":[{"fileName":"src/component-tester.ts","line":37,"character":9}],"signatures":[{"id":76,"name":"bootstrap","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":77,"name":"configure","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":78,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":79,"name":"__type","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":80,"name":"aurelia","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","qualifiedName":"Aurelia","package":"aurelia-framework","name":"Aurelia"}}],"type":{"type":"reference","qualifiedName":"FrameworkConfiguration","package":"aurelia-framework","name":"FrameworkConfiguration"}}]}}}],"type":{"type":"intrinsic","name":"void"}}]},{"id":87,"name":"boundTo","kind":2048,"kindString":"Method","flags":{"isPublic":true},"sources":[{"fileName":"src/component-tester.ts","line":51,"character":9}],"signatures":[{"id":88,"name":"boundTo","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":89,"name":"bindingContext","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":90,"name":"__type","kind":65536,"kindString":"Type literal","flags":{}}}}],"type":{"type":"reference","id":46,"typeArguments":[{"type":"reference","id":49,"name":"T"}],"name":"ComponentTester"}}]},{"id":72,"name":"configure","kind":2048,"kindString":"Method","flags":{"isPublic":true},"sources":[{"fileName":"src/component-tester.ts","line":33,"character":9}],"signatures":[{"id":73,"name":"configure","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":74,"name":"aurelia","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","qualifiedName":"Aurelia","package":"aurelia-framework","name":"Aurelia"}}],"type":{"type":"reference","qualifiedName":"FrameworkConfiguration","package":"aurelia-framework","name":"FrameworkConfiguration"}}]},{"id":93,"name":"create","kind":2048,"kindString":"Method","flags":{"isPublic":true},"sources":[{"fileName":"src/component-tester.ts","line":61,"character":9}],"signatures":[{"id":94,"name":"create","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":95,"name":"bootstrap","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":96,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":97,"name":"__type","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":98,"name":"configure","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":99,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":100,"name":"__type","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":101,"name":"aurelia","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","qualifiedName":"Aurelia","package":"aurelia-framework","name":"Aurelia"}}],"type":{"type":"reference","typeArguments":[{"type":"intrinsic","name":"void"}],"qualifiedName":"Promise","package":"typescript","name":"Promise"}}]}}}],"type":{"type":"reference","typeArguments":[{"type":"intrinsic","name":"void"}],"qualifiedName":"Promise","package":"typescript","name":"Promise"}}]}}}],"type":{"type":"reference","typeArguments":[{"type":"intrinsic","name":"void"}],"qualifiedName":"Promise","package":"typescript","name":"Promise"}}]},{"id":102,"name":"dispose","kind":2048,"kindString":"Method","flags":{"isPublic":true},"sources":[{"fileName":"src/component-tester.ts","line":89,"character":9}],"signatures":[{"id":103,"name":"dispose","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"reference","qualifiedName":"Element","package":"typescript","name":"Element"}}]},{"id":84,"name":"inView","kind":2048,"kindString":"Method","flags":{"isPublic":true},"sources":[{"fileName":"src/component-tester.ts","line":46,"character":9}],"signatures":[{"id":85,"name":"inView","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":86,"name":"html","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"intrinsic","name":"string"}}],"type":{"type":"reference","id":46,"typeArguments":[{"type":"reference","id":49,"name":"T"}],"name":"ComponentTester"}}]},{"id":91,"name":"manuallyHandleLifecycle","kind":2048,"kindString":"Method","flags":{"isPublic":true},"sources":[{"fileName":"src/component-tester.ts","line":56,"character":9}],"signatures":[{"id":92,"name":"manuallyHandleLifecycle","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"reference","id":46,"typeArguments":[{"type":"reference","id":49,"name":"T"}],"name":"ComponentTester"}}]},{"id":106,"name":"waitForElement","kind":2048,"kindString":"Method","flags":{"isPublic":true},"sources":[{"fileName":"src/component-tester.ts","line":139,"character":9}],"signatures":[{"id":107,"name":"waitForElement","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":108,"name":"selector","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"intrinsic","name":"string"}},{"id":109,"name":"options","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"reflection","declaration":{"id":110,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"children":[{"id":112,"name":"interval","kind":1024,"kindString":"Property","flags":{"isOptional":true},"sources":[{"fileName":"src/component-tester.ts","line":141,"character":4}],"type":{"type":"intrinsic","name":"number"}},{"id":111,"name":"present","kind":1024,"kindString":"Property","flags":{"isOptional":true},"sources":[{"fileName":"src/component-tester.ts","line":140,"character":4}],"type":{"type":"intrinsic","name":"boolean"}},{"id":113,"name":"timeout","kind":1024,"kindString":"Property","flags":{"isOptional":true},"sources":[{"fileName":"src/component-tester.ts","line":142,"character":4}],"type":{"type":"intrinsic","name":"number"}}],"groups":[{"title":"Properties","kind":1024,"children":[112,111,113]}]}}}],"type":{"type":"reference","typeArguments":[{"type":"reference","qualifiedName":"Element","package":"typescript","name":"Element"}],"qualifiedName":"Promise","package":"typescript","name":"Promise"}}]},{"id":114,"name":"waitForElements","kind":2048,"kindString":"Method","flags":{"isPublic":true},"sources":[{"fileName":"src/component-tester.ts","line":147,"character":9}],"signatures":[{"id":115,"name":"waitForElements","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":116,"name":"selector","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"intrinsic","name":"string"}},{"id":117,"name":"options","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"reflection","declaration":{"id":118,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"children":[{"id":120,"name":"interval","kind":1024,"kindString":"Property","flags":{"isOptional":true},"sources":[{"fileName":"src/component-tester.ts","line":149,"character":4}],"type":{"type":"intrinsic","name":"number"}},{"id":119,"name":"present","kind":1024,"kindString":"Property","flags":{"isOptional":true},"sources":[{"fileName":"src/component-tester.ts","line":148,"character":4}],"type":{"type":"intrinsic","name":"boolean"}},{"id":121,"name":"timeout","kind":1024,"kindString":"Property","flags":{"isOptional":true},"sources":[{"fileName":"src/component-tester.ts","line":150,"character":4}],"type":{"type":"intrinsic","name":"number"}}],"groups":[{"title":"Properties","kind":1024,"children":[120,119,121]}]}}}],"type":{"type":"reference","typeArguments":[{"type":"reference","typeArguments":[{"type":"reference","qualifiedName":"Element","package":"typescript","name":"Element"}],"qualifiedName":"NodeListOf","package":"typescript","name":"NodeListOf"}],"qualifiedName":"Promise","package":"typescript","name":"Promise"}}]},{"id":81,"name":"withResources","kind":2048,"kindString":"Method","flags":{"isPublic":true},"sources":[{"fileName":"src/component-tester.ts","line":41,"character":9}],"signatures":[{"id":82,"name":"withResources","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":83,"name":"resources","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"union","types":[{"type":"intrinsic","name":"string"},{"type":"array","elementType":{"type":"intrinsic","name":"string"}}]}}],"type":{"type":"reference","id":46,"typeArguments":[{"type":"reference","id":49,"name":"T"}],"name":"ComponentTester"}}]}],"groups":[{"title":"Constructors","kind":512,"children":[47]},{"title":"Properties","kind":1024,"children":[55,50,68,58,64,71,66,67,70,61,65]},{"title":"Methods","kind":2048,"children":[104,75,87,72,93,102,84,91,106,114,81]}],"sources":[{"fileName":"src/component-tester.ts","line":19,"character":13}],"typeParameter":[{"id":122,"name":"T","kind":131072,"kindString":"Type parameter","flags":{},"default":{"type":"intrinsic","name":"any"}}]},{"id":39,"name":"StageComponent","kind":128,"kindString":"Class","flags":{},"children":[{"id":44,"name":"constructor","kind":512,"kindString":"Constructor","flags":{},"signatures":[{"id":45,"name":"new StageComponent","kind":16384,"kindString":"Constructor signature","flags":{},"type":{"type":"reference","id":39,"name":"StageComponent"}}]},{"id":40,"name":"withResources","kind":2048,"kindString":"Method","flags":{"isPublic":true,"isStatic":true},"sources":[{"fileName":"src/component-tester.ts","line":14,"character":16}],"signatures":[{"id":41,"name":"withResources","kind":4096,"kindString":"Call signature","flags":{},"typeParameter":[{"id":42,"name":"T","kind":131072,"kindString":"Type parameter","flags":{},"default":{"type":"intrinsic","name":"any"}}],"parameters":[{"id":43,"name":"resources","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"union","types":[{"type":"intrinsic","name":"string"},{"type":"array","elementType":{"type":"intrinsic","name":"string"}}]},"defaultValue":"[]"}],"type":{"type":"reference","id":46,"typeArguments":[{"type":"reference","id":42,"name":"T"}],"name":"ComponentTester"}}]}],"groups":[{"title":"Constructors","kind":512,"children":[44]},{"title":"Methods","kind":2048,"children":[40]}],"sources":[{"fileName":"src/component-tester.ts","line":13,"character":13}]},{"id":14,"name":"ViewSpy","kind":128,"kindString":"Class","flags":{},"comment":{"shortText":"Attribute to be placed on any HTML element in a view to emit the View instance\nto the debug console, giving you insight into the live View instance, including\nall child views, live bindings, behaviors and more."},"children":[{"id":16,"name":"constructor","kind":512,"kindString":"Constructor","flags":{},"sources":[{"fileName":"src/view-spy.ts","line":22,"character":2}],"signatures":[{"id":17,"name":"new ViewSpy","kind":16384,"kindString":"Constructor signature","flags":{},"comment":{"shortText":"Creates a new instance of ViewSpy."},"type":{"type":"reference","id":14,"name":"ViewSpy"}}]},{"id":18,"name":"logger","kind":1024,"kindString":"Property","flags":{"isPrivate":true},"sources":[{"fileName":"src/view-spy.ts","line":15,"character":10}],"type":{"type":"reference","qualifiedName":"Logger","package":"aurelia-logging","name":"Logger"}},{"id":19,"name":"value","kind":1024,"kindString":"Property","flags":{"isPrivate":true},"sources":[{"fileName":"src/view-spy.ts","line":16,"character":10}],"type":{"type":"intrinsic","name":"any"}},{"id":20,"name":"view","kind":1024,"kindString":"Property","flags":{"isPrivate":true},"sources":[{"fileName":"src/view-spy.ts","line":17,"character":10}],"type":{"type":"intrinsic","name":"any"}},{"id":15,"name":"$resource","kind":1024,"kindString":"Property","flags":{"isStatic":true},"sources":[{"fileName":"src/view-spy.ts","line":10,"character":9}],"type":{"type":"reference","qualifiedName":"IStaticResourceConfig","package":"aurelia-templating","name":"IStaticResourceConfig"},"defaultValue":"..."},{"id":21,"name":"_log","kind":2048,"kindString":"Method","flags":{"isPrivate":true},"sources":[{"fileName":"src/view-spy.ts","line":26,"character":10}],"signatures":[{"id":22,"name":"_log","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":23,"name":"lifecycleName","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"intrinsic","name":"string"}},{"id":24,"name":"context","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"reflection","declaration":{"id":25,"name":"__type","kind":65536,"kindString":"Type literal","flags":{}}}}],"type":{"type":"intrinsic","name":"void"}}]},{"id":33,"name":"attached","kind":2048,"kindString":"Method","flags":{"isPublic":true},"sources":[{"fileName":"src/view-spy.ts","line":54,"character":9}],"signatures":[{"id":34,"name":"attached","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Invoked when the target element is attached to the DOM."},"type":{"type":"intrinsic","name":"void"}}]},{"id":29,"name":"bind","kind":2048,"kindString":"Method","flags":{"isPublic":true},"sources":[{"fileName":"src/view-spy.ts","line":47,"character":9}],"signatures":[{"id":30,"name":"bind","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Invoked when the target view is bound."},"parameters":[{"id":31,"name":"bindingContext","kind":32768,"kindString":"Parameter","flags":{},"comment":{"shortText":"The target view's binding context.\n"},"type":{"type":"reflection","declaration":{"id":32,"name":"__type","kind":65536,"kindString":"Type literal","flags":{}}}}],"type":{"type":"intrinsic","name":"void"}}]},{"id":26,"name":"created","kind":2048,"kindString":"Method","flags":{"isPublic":true},"sources":[{"fileName":"src/view-spy.ts","line":38,"character":9}],"signatures":[{"id":27,"name":"created","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Invoked when the target view is created."},"parameters":[{"id":28,"name":"view","kind":32768,"kindString":"Parameter","flags":{},"comment":{"shortText":"The target view.\n"},"type":{"type":"intrinsic","name":"any"}}],"type":{"type":"intrinsic","name":"void"}}]},{"id":35,"name":"detached","kind":2048,"kindString":"Method","flags":{"isPublic":true},"sources":[{"fileName":"src/view-spy.ts","line":61,"character":9}],"signatures":[{"id":36,"name":"detached","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Invoked when the target element is detached from the DOM."},"type":{"type":"intrinsic","name":"void"}}]},{"id":37,"name":"unbind","kind":2048,"kindString":"Method","flags":{"isPublic":true},"sources":[{"fileName":"src/view-spy.ts","line":68,"character":9}],"signatures":[{"id":38,"name":"unbind","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Invoked when the target element is unbound."},"type":{"type":"intrinsic","name":"void"}}]}],"groups":[{"title":"Constructors","kind":512,"children":[16]},{"title":"Properties","kind":1024,"children":[18,19,20,15]},{"title":"Methods","kind":2048,"children":[21,33,29,26,35,37]}],"sources":[{"fileName":"src/view-spy.ts","line":9,"character":13}]},{"id":1,"name":"configure","kind":64,"kindString":"Function","flags":{},"sources":[{"fileName":"src/aurelia-testing.ts","line":10,"character":16}],"signatures":[{"id":2,"name":"configure","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":3,"name":"config","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","qualifiedName":"FrameworkConfiguration","package":"aurelia-framework","name":"FrameworkConfiguration"}}],"type":{"type":"intrinsic","name":"void"}}]},{"id":123,"name":"waitFor","kind":64,"kindString":"Function","flags":{},"sources":[{"fileName":"src/wait.ts","line":9,"character":16}],"signatures":[{"id":124,"name":"waitFor","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Generic function to wait for something to happen. Uses polling"},"typeParameter":[{"id":125,"name":"T","kind":131072,"kindString":"Type parameter","flags":{}}],"parameters":[{"id":126,"name":"getter","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":127,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":128,"name":"__type","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"reference","id":125,"name":"T"}}]}}},{"id":129,"name":"options","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":130,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"children":[{"id":132,"name":"interval","kind":1024,"kindString":"Property","flags":{"isOptional":true},"sources":[{"fileName":"src/wait.ts","line":11,"character":2}],"type":{"type":"intrinsic","name":"number"}},{"id":131,"name":"present","kind":1024,"kindString":"Property","flags":{"isOptional":true},"sources":[{"fileName":"src/wait.ts","line":10,"character":2}],"type":{"type":"intrinsic","name":"boolean"}},{"id":133,"name":"timeout","kind":1024,"kindString":"Property","flags":{"isOptional":true},"sources":[{"fileName":"src/wait.ts","line":12,"character":2}],"type":{"type":"intrinsic","name":"number"}}],"groups":[{"title":"Properties","kind":1024,"children":[132,131,133]}]}},"defaultValue":"..."}],"type":{"type":"reference","typeArguments":[{"type":"reference","id":125,"name":"T"}],"qualifiedName":"Promise","package":"typescript","name":"Promise"}}]},{"id":134,"name":"waitForDocumentElement","kind":64,"kindString":"Function","flags":{},"sources":[{"fileName":"src/wait.ts","line":48,"character":16}],"signatures":[{"id":135,"name":"waitForDocumentElement","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":136,"name":"selector","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"intrinsic","name":"string"}},{"id":137,"name":"options","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"reflection","declaration":{"id":138,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"children":[{"id":140,"name":"interval","kind":1024,"kindString":"Property","flags":{"isOptional":true},"sources":[{"fileName":"src/wait.ts","line":50,"character":2}],"type":{"type":"intrinsic","name":"number"}},{"id":139,"name":"present","kind":1024,"kindString":"Property","flags":{"isOptional":true},"sources":[{"fileName":"src/wait.ts","line":49,"character":2}],"type":{"type":"intrinsic","name":"boolean"}},{"id":141,"name":"timeout","kind":1024,"kindString":"Property","flags":{"isOptional":true},"sources":[{"fileName":"src/wait.ts","line":51,"character":2}],"type":{"type":"intrinsic","name":"number"}}],"groups":[{"title":"Properties","kind":1024,"children":[140,139,141]}]}}}],"type":{"type":"reference","typeArguments":[{"type":"reference","qualifiedName":"Element","package":"typescript","name":"Element"}],"qualifiedName":"Promise","package":"typescript","name":"Promise"}}]},{"id":142,"name":"waitForDocumentElements","kind":64,"kindString":"Function","flags":{},"sources":[{"fileName":"src/wait.ts","line":56,"character":16}],"signatures":[{"id":143,"name":"waitForDocumentElements","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":144,"name":"selector","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"intrinsic","name":"string"}},{"id":145,"name":"options","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"reflection","declaration":{"id":146,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"children":[{"id":148,"name":"interval","kind":1024,"kindString":"Property","flags":{"isOptional":true},"sources":[{"fileName":"src/wait.ts","line":58,"character":2}],"type":{"type":"intrinsic","name":"number"}},{"id":147,"name":"present","kind":1024,"kindString":"Property","flags":{"isOptional":true},"sources":[{"fileName":"src/wait.ts","line":57,"character":2}],"type":{"type":"intrinsic","name":"boolean"}},{"id":149,"name":"timeout","kind":1024,"kindString":"Property","flags":{"isOptional":true},"sources":[{"fileName":"src/wait.ts","line":59,"character":2}],"type":{"type":"intrinsic","name":"number"}}],"groups":[{"title":"Properties","kind":1024,"children":[148,147,149]}]}}}],"type":{"type":"reference","typeArguments":[{"type":"reference","typeArguments":[{"type":"reference","qualifiedName":"Element","package":"typescript","name":"Element"}],"qualifiedName":"NodeListOf","package":"typescript","name":"NodeListOf"}],"qualifiedName":"Promise","package":"typescript","name":"Promise"}}]}],"groups":[{"title":"Classes","kind":128,"children":[4,46,39,14]},{"title":"Functions","kind":64,"children":[1,123,134,142]}],"sources":[{"fileName":"src/aurelia-testing.ts","line":1,"character":0}]}
--------------------------------------------------------------------------------
/doc/cleanup.js:
--------------------------------------------------------------------------------
1 | const path = require('path').resolve(__dirname, 'api.json');
2 | const content = JSON.stringify(require('./api.json'));
3 |
4 | require('fs').writeFileSync(path, content, { encoding: 'utf-8' });
5 |
--------------------------------------------------------------------------------
/doc/shape-defs.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 | const fs = require('fs');
5 | const packageJsonPath = path.resolve(__dirname, '../package.json');
6 |
7 | try {
8 | const packageName = require(packageJsonPath).name;
9 | const dtsPath = path.resolve(__dirname, `../dist/doc-temp/${packageName}.d.ts`);
10 | let defs = fs.readFileSync(dtsPath).toString();
11 |
12 | // aggregate external imports
13 | const packages = {};
14 | const importRegex = /^\s*import\s+\{([^}]+)\}\s*from\s*'([\w|-]+)'/gm;
15 | let importMatch = importRegex.exec(defs);
16 | while (importMatch) {
17 | const packageName = importMatch[2];
18 | const imports = packages[packageName] || (packages[packageName] = []);
19 | const bindings = importMatch[1].split(',').map(x => x.trim());
20 | for (let binding of bindings) {
21 | if (imports.indexOf(binding) === -1) {
22 | imports.push(binding);
23 | }
24 | }
25 | importMatch = importRegex.exec(defs);
26 | }
27 |
28 | // remove leading declare module
29 | defs = defs.replace(/^declare module ".*" \{/, '');
30 | // remove "} declare module {"
31 | defs = defs.replace(/\}\r?\ndeclare module ".*" \{/g, '');
32 | // remove closing "}"
33 | defs = defs.replace(/\}\r?\n$/, '');
34 | // remove imports
35 | defs = defs.replace(/^\s+import.*;$/gm, '');
36 | // remove "export *"
37 | defs = defs.replace(/^\s+export \*.*;$/gm, '');
38 |
39 | // write imports
40 | for (let packageName in packages) {
41 | if (packages.hasOwnProperty(packageName)) {
42 | const imports = packages[packageName];
43 | defs = `import {${imports.sort()}} from '${packageName}';\n` + defs;
44 | }
45 | }
46 |
47 | fs.writeFileSync(dtsPath, defs);
48 | console.log(`Shaped the dist/doc-temp/${packageName}.d.ts file.`);
49 | } catch (e) {
50 | console.error(`Unable to shape the .d.ts file.`);
51 | console.error(e.message);
52 | }
53 |
--------------------------------------------------------------------------------
/doc/shape-doc.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require('path');
4 | const fs = require('fs');
5 | const packageJsonPath = path.resolve(__dirname, '../package.json');
6 | const apiJsonPath = path.resolve(__dirname, './api.json');
7 |
8 | try {
9 | const packageName = require(packageJsonPath).name;
10 | let json = require(apiJsonPath);
11 |
12 | json = {
13 | name: packageName,
14 | children: json.children
15 | .filter(child => !child.name.startsWith('"test/'))
16 | .map(child => {
17 | return {
18 | name: child.name,
19 | children: child.children,
20 | groups: child.groups
21 | };
22 | }),
23 | groups: json.groups
24 | };
25 |
26 | const str = JSON.stringify(json) + '\n';
27 | fs.writeFileSync(apiJsonPath, str);
28 | console.log('Shaped the doc/api.json file.');
29 | } catch (e) {
30 | console.error('Unable to shape the api.json. The file probably has an incorrect format or doesn\'t exist.');
31 | console.error(e.message);
32 | }
33 |
--------------------------------------------------------------------------------
/karma.conf.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const { AureliaPlugin } = require('aurelia-webpack-plugin');
3 |
4 | module.exports = function(config) {
5 | const browsers = config.browsers;
6 | config.set({
7 |
8 | basePath: '',
9 | frameworks: ["jasmine"],
10 | files: ["test/**/*.spec.ts"],
11 | preprocessors: {
12 | "test/**/*.spec.ts": ["webpack", "sourcemap"],
13 | },
14 | webpack: {
15 | mode: "development",
16 | entry: 'test/setup.ts',
17 | watch: false,
18 | resolve: {
19 | extensions: [".ts", ".js"],
20 | modules: ["src", 'test', "node_modules"].map(m => path.resolve(__dirname, m)),
21 | alias: {
22 | src: path.resolve(__dirname, "src"),
23 | test: path.resolve(__dirname, 'test'),
24 | 'aurelia-testing': path.resolve(__dirname, 'src/aurelia-testing.ts')
25 | }
26 | },
27 | devtool: browsers.indexOf('ChromeDebugging') > -1 ? 'eval-source-map' : 'inline-source-map',
28 | module: {
29 | rules: [
30 | {
31 | test: /\.ts$/,
32 | loader: "ts-loader",
33 | exclude: /node_modules/,
34 | options: {
35 | compilerOptions: {
36 | sourceMap: true
37 | }
38 | }
39 | },
40 | {
41 | test: /\.html$/i,
42 | loader: 'html-loader'
43 | }
44 | ]
45 | },
46 | plugins: [
47 | new AureliaPlugin({ aureliaApp: undefined, dist: 'es2015' })
48 | ]
49 | },
50 | mime: {
51 | "text/x-typescript": ["ts"]
52 | },
53 | reporters: ["mocha"],
54 | webpackServer: { noInfo: config.noInfo },
55 | browsers: browsers && browsers.length > 0 ? browsers : ['ChromeHeadless'],
56 | customLaunchers: {
57 | ChromeDebugging: {
58 | base: "Chrome",
59 | flags: ["--remote-debugging-port=9333"],
60 | debug: true
61 | }
62 | },
63 | singleRun: false,
64 | mochaReporter: {
65 | ignoreSkipped: true
66 | },
67 | webpackMiddleware: {
68 | logLevel: 'silent'
69 | },
70 | });
71 | };
72 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "aurelia-testing",
3 | "version": "1.1.0",
4 | "description": "A collection of helpers for testing Aurelia apps and components.",
5 | "keywords": [
6 | "aurelia",
7 | "testing"
8 | ],
9 | "homepage": "http://aurelia.io",
10 | "bugs": {
11 | "url": "https://github.com/aurelia/testing/issues"
12 | },
13 | "license": "MIT",
14 | "author": "Rob Eisenberg (http://robeisenberg.com/)",
15 | "main": "dist/commonjs/aurelia-testing.js",
16 | "typings": "dist/types/aurelia-testing.d.ts",
17 | "repository": {
18 | "type": "git",
19 | "url": "http://github.com/aurelia/testing"
20 | },
21 | "files": [
22 | "dist",
23 | "doc/CHANGELOG.md",
24 | "LICENSE",
25 | "typings.json"
26 | ],
27 | "scripts": {
28 | "test": "karma start --single-run",
29 | "test:watch": "karma start",
30 | "test:debugger": "karma start --browsers ChromeDebugging",
31 | "lint": "eslint .",
32 | "prebuild": "rimraf dist",
33 | "build": "rollup -c",
34 | "build:dts": "dts-bundle-generator -o dist/types/aurelia-testing.d.ts src/aurelia-testing.ts",
35 | "postbuild": "npm run build:dts",
36 | "typedoc": "typedoc src/aurelia-testing.ts --json doc/api.json",
37 | "posttypedoc": "node doc/cleanup.js",
38 | "changelog": "standard-version -t \"\" -i doc/CHANGELOG.md --skip.commit --skip.tag",
39 | "precut-release": "npm run test && npm run lint && npm run build",
40 | "cut-release": "npm run changelog",
41 | "postcut-release": "npm run typedoc"
42 | },
43 | "dependencies": {
44 | "aurelia-dependency-injection": "^1.0.0",
45 | "aurelia-framework": "^1.4.1",
46 | "aurelia-logging": "^1.0.0",
47 | "aurelia-pal": "^1.0.0",
48 | "aurelia-templating": "^1.11.1"
49 | },
50 | "devDependencies": {
51 | "@rollup/plugin-typescript": "^8.3.2",
52 | "@types/jasmine": "^4.0.3",
53 | "@types/estree": "0.0.51",
54 | "@typescript-eslint/eslint-plugin": "^5.17.0",
55 | "@typescript-eslint/parser": "^5.17.0",
56 | "eslint": "^8.12.0",
57 | "aurelia-bootstrapper": "^2.4.0",
58 | "aurelia-pal-browser": "^1.3.0",
59 | "aurelia-polyfills": "^1.2.2",
60 | "aurelia-webpack-plugin": "^5.0.4",
61 | "concurrently": "^7.1.0",
62 | "cross-env": "^7.0.3",
63 | "dts-bundle-generator": "^6.9.0",
64 | "html-loader": "^3.1.0",
65 | "jasmine-core": "^4.1.0",
66 | "karma": "^6.3.19",
67 | "karma-chrome-launcher": "^3.1.1",
68 | "karma-coverage": "^2.2.0",
69 | "karma-jasmine": "^5.0.0",
70 | "karma-mocha-reporter": "^2.2.5",
71 | "karma-sourcemap-loader": "^0.3.8",
72 | "karma-webpack": "^5.0.0",
73 | "rimraf": "^3.0.2",
74 | "rollup": "^2.72.0",
75 | "standard-version": "^9.3.2",
76 | "ts-loader": "^9.3.0",
77 | "tslib": "^2.4.0",
78 | "typedoc": "^0.22.15",
79 | "typescript": "^4.6.4",
80 | "webpack": "^5.72.0",
81 | "webpack-cli": "^4.9.2"
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import typescript from '@rollup/plugin-typescript';
2 | import pkg from './package.json';
3 |
4 | const { name } = pkg;
5 | const inputFileName = `src/${name}.ts`;
6 |
7 | export default [
8 | {
9 | input: inputFileName,
10 | output: [
11 | {
12 | file: `dist/es2015/${name}.js`,
13 | format: 'esm'
14 | }
15 | ],
16 | plugins: [
17 | typescript({
18 | removeComments: true
19 | })
20 | ]
21 | },
22 | {
23 | input: inputFileName,
24 | output: [{
25 | file: `dist/es2017/${name}.js`,
26 | format: 'esm'
27 | }],
28 | plugins: [
29 | typescript({
30 | target: 'es2017',
31 | removeComments: true
32 | })
33 | ]
34 | },
35 | {
36 | input: inputFileName,
37 | output: [
38 | { file: `dist/amd/${name}.js`, format: 'amd', amd: { id: name } },
39 | { file: `dist/commonjs/${name}.js`, format: 'cjs' },
40 | { file: `dist/system/${name}.js`, format: 'system' },
41 | { file: `dist/native-modules/${name}.js`, format: 'esm' }
42 | ],
43 | plugins: [
44 | typescript({
45 | target: 'es5',
46 | removeComments: true
47 | })
48 | ]
49 | }
50 | ].map(config => {
51 | config.external = [
52 | 'aurelia-binding',
53 | 'aurelia-dependency-injection',
54 | 'aurelia-pal',
55 | 'aurelia-templating',
56 | 'aurelia-task-queue',
57 | 'aurelia-logging',
58 | 'aurelia-path',
59 | 'aurelia-loader',
60 | 'aurelia-metadata'
61 | ];
62 | config.output.forEach(output => output.sourcemap = true);
63 | config.onwarn = /** @param {import('rollup').RollupWarning} warning */ (warning, warn) => {
64 | if (warning.code === 'CIRCULAR_DEPENDENCY') return;
65 | warn(warning);
66 | };
67 |
68 | return config;
69 | });
70 |
--------------------------------------------------------------------------------
/src/aurelia-testing.ts:
--------------------------------------------------------------------------------
1 | import type { FrameworkConfiguration } from 'aurelia-framework';
2 | import { CompileSpy } from './compile-spy';
3 | import { ViewSpy } from './view-spy';
4 |
5 | export * from './compile-spy';
6 | export * from './view-spy';
7 | export * from './component-tester';
8 | export * from './wait';
9 |
10 | export function configure(config: FrameworkConfiguration) {
11 | config.globalResources([CompileSpy, ViewSpy]);
12 | }
13 |
--------------------------------------------------------------------------------
/src/compile-spy.ts:
--------------------------------------------------------------------------------
1 | import { type IStaticResourceConfig, TargetInstruction } from 'aurelia-templating';
2 | import { getLogger } from 'aurelia-logging';
3 | import { DOM } from 'aurelia-pal';
4 |
5 | /**
6 | * Attribute to be placed on any element to have it emit the View Compiler's
7 | * TargetInstruction into the debug console, giving you insight into all the
8 | * parsed bindings, behaviors and event handers for the targeted element.
9 | */
10 | export class CompileSpy {
11 | /** @internal */
12 | static get inject() { return [DOM.Element, TargetInstruction]; }
13 | /** @internal */
14 | static $resource: IStaticResourceConfig = {
15 | type: 'attribute',
16 | name: 'compile-spy'
17 | }
18 | /**
19 | * Creates and instanse of CompileSpy.
20 | * @param element target element on where attribute is placed on.
21 | * @param instruction instructions for how the target element should be enhanced.
22 | */
23 | constructor(element: Element, instruction: TargetInstruction) {
24 | getLogger('compile-spy').info(element.toString(), instruction);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/component-tester.ts:
--------------------------------------------------------------------------------
1 | import { View } from 'aurelia-templating';
2 | import type { Aurelia, FrameworkConfiguration } from 'aurelia-framework';
3 | import { waitFor } from './wait';
4 |
5 | interface AureliaWithRoot extends Aurelia {
6 | root: ViewWithControllers;
7 | }
8 |
9 | interface ViewWithControllers extends View {
10 | controllers: {viewModel: any}[];
11 | }
12 |
13 | export class StageComponent {
14 | public static withResources(resources: string | string[] = []): ComponentTester {
15 | return new ComponentTester().withResources(resources);
16 | }
17 | }
18 |
19 | export class ComponentTester {
20 | public bind: (bindingContext: {}) => Promise;
21 | public attached: () => Promise;
22 | public detached: () => Promise;
23 | public unbind: () => Promise;
24 | public element: Element;
25 | public viewModel: T;
26 |
27 | private html: string;
28 | private resources: string | Function | (string | Function)[] = [];
29 | private bindingContext: {};
30 | private rootView: View;
31 | private host: HTMLDivElement;
32 |
33 | public configure(aurelia: Aurelia): FrameworkConfiguration {
34 | return aurelia.use.standardConfiguration();
35 | }
36 |
37 | public bootstrap(configure: (aurelia: Aurelia) => FrameworkConfiguration) {
38 | this.configure = configure;
39 | }
40 |
41 | public withResources(resources: string | string[]): this {
42 | this.resources = resources;
43 | return this;
44 | }
45 |
46 | public inView(html: string): this {
47 | this.html = html;
48 | return this;
49 | }
50 |
51 | public boundTo(bindingContext: {}): this {
52 | this.bindingContext = bindingContext;
53 | return this;
54 | }
55 |
56 | public manuallyHandleLifecycle(): this {
57 | this._prepareLifecycle();
58 | return this;
59 | }
60 |
61 | public create(bootstrap: (configure: (aurelia: Aurelia) => Promise) => Promise): Promise {
62 | return bootstrap((aurelia: AureliaWithRoot) => {
63 | return Promise.resolve(this.configure(aurelia)).then(() => {
64 | if (this.resources) {
65 | aurelia.use.globalResources(this.resources);
66 | }
67 |
68 | return aurelia.start().then(() => {
69 | this.host = document.createElement('div');
70 | this.host.innerHTML = this.html;
71 |
72 | document.body.appendChild(this.host);
73 |
74 | return aurelia.enhance(this.bindingContext, this.host).then(() => {
75 | this.rootView = aurelia.root;
76 | this.element = this.host.firstElementChild as Element;
77 |
78 | if (aurelia.root.controllers.length) {
79 | this.viewModel = aurelia.root.controllers[0].viewModel;
80 | }
81 |
82 | return new Promise(resolve => setTimeout(() => resolve(), 0)) as Promise;
83 | });
84 | });
85 | });
86 | });
87 | }
88 |
89 | public dispose(): Element {
90 | if (this.host === undefined || this.rootView === undefined) {
91 | throw new Error(
92 | 'Cannot call ComponentTester.dispose() before ComponentTester.create()'
93 | );
94 | }
95 |
96 | this.rootView.detached();
97 | this.rootView.unbind();
98 |
99 | return (this.host.parentNode as Node).removeChild(this.host);
100 | }
101 |
102 | private _prepareLifecycle() {
103 | // bind
104 | const bindPrototype = View.prototype.bind;
105 | // tslint:disable-next-line:no-empty
106 | View.prototype.bind = () => {};
107 | this.bind = bindingContext => new Promise(resolve => {
108 | View.prototype.bind = bindPrototype;
109 | if (bindingContext !== undefined) {
110 | this.bindingContext = bindingContext;
111 | }
112 | this.rootView.bind(this.bindingContext);
113 | setTimeout(() => resolve(), 0);
114 | });
115 |
116 | // attached
117 | const attachedPrototype = View.prototype.attached;
118 | // tslint:disable-next-line:no-empty
119 | View.prototype.attached = () => {};
120 | this.attached = () => new Promise(resolve => {
121 | View.prototype.attached = attachedPrototype;
122 | this.rootView.attached();
123 | setTimeout(() => resolve(), 0);
124 | });
125 |
126 | // detached
127 | this.detached = () => new Promise(resolve => {
128 | this.rootView.detached();
129 | setTimeout(() => resolve(), 0);
130 | });
131 |
132 | // unbind
133 | this.unbind = () => new Promise(resolve => {
134 | this.rootView.unbind();
135 | setTimeout(() => resolve(), 0);
136 | });
137 | }
138 |
139 | public waitForElement(selector: string, options?: {
140 | present?: boolean,
141 | interval?: number,
142 | timeout?: number
143 | }): Promise {
144 | return waitFor(() => this.element.querySelector(selector) as Element, options);
145 | }
146 |
147 | public waitForElements(selector: string, options?: {
148 | present?: boolean,
149 | interval?: number,
150 | timeout?: number
151 | }): Promise> {
152 | return waitFor(() => this.element.querySelectorAll(selector) as NodeListOf, options);
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/src/view-spy.ts:
--------------------------------------------------------------------------------
1 | import { IStaticResourceConfig } from 'aurelia-templating';
2 | import { getLogger, Logger } from 'aurelia-logging';
3 |
4 | /**
5 | * Attribute to be placed on any HTML element in a view to emit the View instance
6 | * to the debug console, giving you insight into the live View instance, including
7 | * all child views, live bindings, behaviors and more.
8 | */
9 | export class ViewSpy {
10 | static $resource: IStaticResourceConfig = {
11 | type: 'attribute',
12 | name: 'view-spy'
13 | };
14 |
15 | private logger: Logger;
16 | private value: any;
17 | private view: any;
18 |
19 | /**
20 | * Creates a new instance of ViewSpy.
21 | */
22 | constructor() {
23 | this.logger = getLogger('view-spy');
24 | }
25 |
26 | private _log(lifecycleName: string, context?: {}) {
27 | if (!this.value && lifecycleName === 'created') {
28 | this.logger.info(lifecycleName, this.view);
29 | } else if (this.value && this.value.indexOf(lifecycleName) !== -1) {
30 | this.logger.info(lifecycleName, this.view, context);
31 | }
32 | }
33 |
34 | /**
35 | * Invoked when the target view is created.
36 | * @param view The target view.
37 | */
38 | public created(view: any) {
39 | this.view = view;
40 | this._log('created');
41 | }
42 |
43 | /**
44 | * Invoked when the target view is bound.
45 | * @param bindingContext The target view's binding context.
46 | */
47 | public bind(bindingContext: {}) {
48 | this._log('bind', bindingContext);
49 | }
50 |
51 | /**
52 | * Invoked when the target element is attached to the DOM.
53 | */
54 | public attached() {
55 | this._log('attached');
56 | }
57 |
58 | /**
59 | * Invoked when the target element is detached from the DOM.
60 | */
61 | public detached() {
62 | this._log('detached');
63 | }
64 |
65 | /**
66 | * Invoked when the target element is unbound.
67 | */
68 | public unbind() {
69 | this._log('unbind');
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/wait.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Generic function to wait for something to happen. Uses polling
3 | * @param getter: a getter function that returns anything else than `null` or an
4 | * empty array or an empty jQuery object when the
5 | * condition is met
6 | * @param options: lookup options, defaults to
7 | * `{present: true, interval: 50, timeout: 5000}`
8 | */
9 | export function waitFor(getter: () => T, options: {
10 | present?: boolean,
11 | interval?: number,
12 | timeout?: number
13 | } = {present: true, interval: 50, timeout: 5000}): Promise {
14 | // prevents infinite recursion if the request times out
15 | let timedOut = false;
16 |
17 | options = {
18 | present: true,
19 | interval: 50,
20 | timeout: 5000,
21 | ...options
22 | };
23 |
24 | function wait(): Promise {
25 | const element = getter();
26 | // boolean is needed here, hence the length > 0
27 | const found = element !== null && (!(element instanceof NodeList) &&
28 | !(element as any).jquery || (element as any).length > 0);
29 |
30 | if (!options.present === !found || timedOut) {
31 | return Promise.resolve(element);
32 | }
33 |
34 | return new Promise(rs => setTimeout(rs, options.interval)).then(wait);
35 | }
36 |
37 | return Promise.race([
38 | new Promise(
39 | (_, rj) => setTimeout(() => {
40 | timedOut = true;
41 | rj(new Error(options.present ? 'Element not found' : 'Element not removed'));
42 | }, options.timeout)
43 | ),
44 | wait()
45 | ]) as Promise;
46 | }
47 |
48 | export function waitForDocumentElement(selector: string, options?: {
49 | present?: boolean,
50 | interval?: number,
51 | timeout?: number
52 | }): Promise {
53 | return waitFor(() => document.querySelector(selector) as Element, options);
54 | }
55 |
56 | export function waitForDocumentElements(selector: string, options?: {
57 | present?: boolean,
58 | interval?: number,
59 | timeout?: number
60 | }): Promise> {
61 | return waitFor(() => document.querySelectorAll(selector), options);
62 | }
63 |
--------------------------------------------------------------------------------
/test/component-tester.spec.ts:
--------------------------------------------------------------------------------
1 | import { StageComponent, ComponentTester } from '../src/aurelia-testing';
2 | import { bootstrap } from 'aurelia-bootstrapper';
3 | import { PLATFORM } from 'aurelia-pal';
4 |
5 | describe('ComponentTester', () => {
6 | let component: ComponentTester;
7 |
8 | beforeEach(() => {
9 | debugger
10 | component = StageComponent
11 | .withResources(PLATFORM.moduleName('resources/my-component'))
12 | .inView(`
13 |
14 |
15 |
16 |
17 | Number two
18 |
19 |
`)
20 | .boundTo({ firstName: 'Bob' });
21 | });
22 |
23 | it('should wait for a child element', (done) => {
24 | component.create(bootstrap)
25 | .then(() => {
26 | return component.waitForElement('my-component');
27 | })
28 | .then((element) => {
29 | expect(element.nodeName.toLowerCase()).toEqual('my-component');
30 | done();
31 | })
32 | .catch(done.fail);
33 | });
34 |
35 | it('should wait for multiple child elements', (done) => {
36 | component.create(bootstrap)
37 | .then(() => {
38 | return component.waitForElements('.component-tester-spec');
39 | })
40 | .then((elements) => {
41 | expect(elements.length).toBe(2);
42 | done();
43 | })
44 | .catch(done.fail);
45 | });
46 |
47 | afterEach(() => {
48 | component.dispose();
49 | });
50 | });
51 |
--------------------------------------------------------------------------------
/test/doc-samples.spec.ts:
--------------------------------------------------------------------------------
1 | import { StageComponent, ComponentTester } from '../src/aurelia-testing';
2 | import { bootstrap } from 'aurelia-bootstrapper';
3 | import { PLATFORM } from 'aurelia-pal';
4 |
5 | describe('SampleCustomComponent', () => {
6 | let component: ComponentTester;
7 |
8 | beforeEach(() => {
9 | component = StageComponent
10 | .withResources(PLATFORM.moduleName('resources/my-component'))
11 | .inView('')
12 | .boundTo({ firstName: 'Bob' });
13 | });
14 |
15 | it('should render first name', done => {
16 | component.create(bootstrap)
17 | .then(() => {
18 | const nameElement = document.querySelector('.firstName') as Element;
19 | expect(nameElement.innerHTML).toBe('Bob');
20 | done();
21 | })
22 | .catch(done.fail);
23 | });
24 |
25 | afterEach(() => {
26 | component.dispose();
27 | });
28 | });
29 |
30 | describe('SampleCustomAttribute', () => {
31 | let component: ComponentTester;
32 |
33 | beforeEach(() => {
34 | component = StageComponent
35 | .withResources(PLATFORM.moduleName('resources/my-attribute'))
36 | .inView('Bob
')
37 | .boundTo({ color: 'blue' });
38 | });
39 |
40 | it('should set the background color to provided color', done => {
41 | component.create(bootstrap)
42 | .then(() => {
43 | expect((component.element as HTMLElement).style.backgroundColor).toBe('blue');
44 | done();
45 | })
46 | .catch(done.fail);
47 | });
48 |
49 | afterEach(() => {
50 | component.dispose();
51 | });
52 | });
53 |
--------------------------------------------------------------------------------
/test/resources/my-attribute.ts:
--------------------------------------------------------------------------------
1 | export class MyAttributeCustomAttribute {
2 | public static inject = [Element];
3 |
4 | constructor(public element: Element) {}
5 |
6 | public valueChanged(newValue: string) {
7 | (this.element as HTMLElement).style.backgroundColor = newValue;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/test/resources/my-component.html:
--------------------------------------------------------------------------------
1 |
2 | ${firstName}
3 |
4 |
--------------------------------------------------------------------------------
/test/resources/my-component.ts:
--------------------------------------------------------------------------------
1 | import { bindable } from 'aurelia-framework';
2 |
3 | export class MyComponent {
4 | @bindable public firstName: string;
5 | }
6 |
--------------------------------------------------------------------------------
/test/setup.ts:
--------------------------------------------------------------------------------
1 | import 'aurelia-polyfills';
2 | import { initialize } from 'aurelia-pal-browser';
3 |
4 | initialize();
5 |
--------------------------------------------------------------------------------
/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "paths": {
5 | "aurelia-testing": ["../src/aurelia-testing.ts"]
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "amd",
4 | "moduleResolution": "node",
5 | "target": "es5",
6 | "lib": [
7 | "es2017",
8 | "dom"
9 | ],
10 | "outDir": "dist/amd",
11 | "noImplicitAny": true,
12 | "noUnusedLocals": true,
13 | "noUnusedParameters": true,
14 | "noImplicitReturns": true,
15 | "strictNullChecks": true,
16 | "declaration": true,
17 | "forceConsistentCasingInFileNames": true,
18 | "experimentalDecorators": true,
19 | "noEmitHelpers": false,
20 | "stripInternal": true
21 | },
22 | "exclude": [
23 | ".vscode",
24 | "dist",
25 | "doc",
26 | "node_modules",
27 | "test"
28 | ]
29 | }
30 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2015",
4 | "module": "es2015",
5 | "experimentalDecorators": true,
6 | "emitDecoratorMetadata": false,
7 | "moduleResolution": "node",
8 | "stripInternal": true,
9 | "lib": ["es2015", "dom"]
10 | },
11 | "exclude": [
12 | "node_modules",
13 | "dist",
14 | "build",
15 | "doc",
16 | "config.js",
17 | "gulpfile.js",
18 | "karma.conf.js"
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "tslint:latest",
3 | "rules": {
4 | "quotemark": [true, "single"],
5 | "object-literal-sort-keys": false,
6 | "ordered-imports": [false],
7 | "whitespace": [true, "check-branch", "check-decl", "check-operator", "check-module", "check-separator", "check-type"],
8 | "interface-name": [true, "never-prefix"],
9 | "no-shadowed-variable": false,
10 | "no-string-literal": false,
11 | "trailing-comma": [false],
12 | "member-ordering": ["fields-first"],
13 | "array-type": ["array-simple"],
14 | "arrow-parens": false,
15 | "max-classes-per-file": [false],
16 | "prefer-for-of": false,
17 | "prefer-conditional-expression": false,
18 | "no-implicit-dependencies": [true, "dev"]
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/typings.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "aurelia-testing",
3 | "main": "dist/types/aurelia-testing.d.ts"
4 | }
5 |
--------------------------------------------------------------------------------