diff --git a/bower.json b/bower.json index d7167d1..5eb6f27 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "aurelia-testing", - "version": "1.0.0-beta.2.0.1", + "version": "1.0.0-beta.3.0.0", "description": "A collection of helpers for testing Aurelia apps and components.", "keywords": [ "aurelia", diff --git a/config.js b/config.js index 63d7486..36814bc 100644 --- a/config.js +++ b/config.js @@ -14,6 +14,33 @@ System.config({ "aurelia-pal-browser": "npm:aurelia-pal-browser@1.0.0", "aurelia-polyfills": "npm:aurelia-polyfills@1.0.0", "aurelia-templating": "npm:aurelia-templating@1.0.0", + "babel": "npm:babel-core@5.8.38", + "babel-runtime": "npm:babel-runtime@5.8.38", + "core-js": "npm:core-js@1.2.7", + "github:jspm/nodelibs-assert@0.1.0": { + "assert": "npm:assert@1.4.1" + }, + "github:jspm/nodelibs-buffer@0.1.0": { + "buffer": "npm:buffer@3.6.0" + }, + "github:jspm/nodelibs-path@0.1.0": { + "path-browserify": "npm:path-browserify@0.0.0" + }, + "github:jspm/nodelibs-process@0.1.2": { + "process": "npm:process@0.11.9" + }, + "github:jspm/nodelibs-util@0.1.0": { + "util": "npm:util@0.10.3" + }, + "github:jspm/nodelibs-vm@0.1.0": { + "vm-browserify": "npm:vm-browserify@0.0.4" + }, + "npm:assert@1.4.1": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2", + "util": "npm:util@0.10.3" + }, "npm:aurelia-binding@1.0.0": { "aurelia-logging": "npm:aurelia-logging@1.0.0", "aurelia-metadata": "npm:aurelia-metadata@1.0.0", @@ -127,6 +154,41 @@ System.config({ "aurelia-pal": "npm:aurelia-pal@1.0.0", "aurelia-path": "npm:aurelia-path@1.0.0", "aurelia-task-queue": "npm:aurelia-task-queue@1.0.0" + }, + "npm:babel-runtime@5.8.38": { + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:buffer@3.6.0": { + "base64-js": "npm:base64-js@0.0.8", + "child_process": "github:jspm/nodelibs-child_process@0.1.0", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "ieee754": "npm:ieee754@1.1.8", + "isarray": "npm:isarray@1.0.0", + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:core-js@1.2.7": { + "fs": "github:jspm/nodelibs-fs@0.1.2", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2", + "systemjs-json": "github:systemjs/plugin-json@0.1.2" + }, + "npm:inherits@2.0.1": { + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:path-browserify@0.0.0": { + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:process@0.11.9": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "vm": "github:jspm/nodelibs-vm@0.1.0" + }, + "npm:util@0.10.3": { + "inherits": "npm:inherits@2.0.1", + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:vm-browserify@0.0.4": { + "indexof": "npm:indexof@0.0.1" } } }); diff --git a/dist/amd/aurelia-testing.js b/dist/amd/aurelia-testing.js index 4609e08..32faad0 100644 --- a/dist/amd/aurelia-testing.js +++ b/dist/amd/aurelia-testing.js @@ -1,10 +1,10 @@ -define(['exports', './compile-spy', './view-spy', './component-tester'], function (exports, _compileSpy, _viewSpy, _componentTester) { +define(['exports', './compile-spy', './view-spy', './component-tester', './wait'], function (exports, _compileSpy, _viewSpy, _componentTester, _wait) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); - exports.configure = exports.ComponentTester = exports.StageComponent = exports.ViewSpy = exports.CompileSpy = undefined; + exports.waitForDocumentElements = exports.waitForDocumentElement = exports.waitFor = exports.configure = exports.ComponentTester = exports.StageComponent = exports.ViewSpy = exports.CompileSpy = undefined; function configure(config) { @@ -16,4 +16,7 @@ define(['exports', './compile-spy', './view-spy', './component-tester'], functio exports.StageComponent = _componentTester.StageComponent; exports.ComponentTester = _componentTester.ComponentTester; exports.configure = configure; + exports.waitFor = _wait.waitFor; + exports.waitForDocumentElement = _wait.waitForDocumentElement; + exports.waitForDocumentElements = _wait.waitForDocumentElements; }); \ No newline at end of file diff --git a/dist/amd/component-tester.js b/dist/amd/component-tester.js index 93575e6..ad5cea8 100644 --- a/dist/amd/component-tester.js +++ b/dist/amd/component-tester.js @@ -8,11 +8,17 @@ define(['exports', 'aurelia-templating', 'aurelia-framework'], function (exports - var StageComponent = exports.StageComponent = { - withResources: function withResources(resources) { - return new ComponentTester().withResources(resources); + var StageComponent = exports.StageComponent = function () { + function StageComponent() { + } - }; + + StageComponent.withResources = function withResources(resources) { + return new ComponentTester().withResources(resources); + }; + + return StageComponent; + }(); var ComponentTester = exports.ComponentTester = function () { function ComponentTester() { @@ -143,6 +149,22 @@ define(['exports', 'aurelia-templating', 'aurelia-framework'], function (exports }; }; + ComponentTester.prototype.waitForElement = function waitForElement(selector, options) { + var _this3 = this; + + return waitFor(function () { + return _this3.element.querySelector(selector); + }, options); + }; + + ComponentTester.prototype.waitForElements = function waitForElements(selector, options) { + var _this4 = this; + + return waitFor(function () { + return _this4.element.querySelectorAll(selector); + }, options); + }; + return ComponentTester; }(); }); \ No newline at end of file diff --git a/dist/amd/wait.js b/dist/amd/wait.js new file mode 100644 index 0000000..76f2624 --- /dev/null +++ b/dist/amd/wait.js @@ -0,0 +1,52 @@ +define(['exports'], function (exports) { + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.waitFor = waitFor; + exports.waitForDocumentElement = waitForDocumentElement; + exports.waitForDocumentElements = waitForDocumentElements; + function waitFor(getter, options) { + var timedOut = false; + + options = Object.assign({ + present: true, + interval: 50, + timeout: 5000 + }, options); + + function wait() { + var element = getter(); + + var found = element !== null && (!(element instanceof NodeList) && !element.jquery || element.length > 0); + + if (!options.present ^ found || timedOut) { + return Promise.resolve(element); + } + + return new Promise(function (rs) { + return setTimeout(rs, options.interval); + }).then(wait); + } + + return Promise.race([new Promise(function (rs, rj) { + return setTimeout(function () { + timedOut = true; + rj(options.present ? 'Element not found' : 'Element not removed'); + }, options.timeout); + }), wait()]); + } + + function waitForDocumentElement(selector, options) { + return waitFor(function () { + return document.querySelector(selector); + }, options); + } + + function waitForDocumentElements(selector, options) { + return waitFor(function () { + return document.querySelectorAll(selector); + }, options); + } +}); \ No newline at end of file diff --git a/dist/aurelia-testing.d.ts b/dist/aurelia-testing.d.ts index 312f1e3..6c8859d 100644 --- a/dist/aurelia-testing.d.ts +++ b/dist/aurelia-testing.d.ts @@ -13,7 +13,21 @@ import { import { DOM } from 'aurelia-pal'; -export declare const StageComponent: any; + +/** + * Generic function to wait for something to happen. Uses polling + * @param getter: a getter function that returns anything else than `null` or an + * empty array or an empty jQuery object when the + * condition is met + * @param options: lookup options, defaults to + * `{present: true, interval: 50, timeout: 5000}` + */ +export declare function waitFor(getter: (() => any), options: any): Promise; +export declare function waitForDocumentElement(selector: string, options: any): Promise; +export declare function waitForDocumentElements(selector: string, options: any): Promise; +export declare class StageComponent { + static withResources(resources: string | string[]): ComponentTester; +} export declare class ComponentTester { bind: ((bindingContext: any) => void); attached: (() => void); @@ -26,8 +40,10 @@ export declare class ComponentTester { inView(html: string): ComponentTester; boundTo(bindingContext: any): ComponentTester; manuallyHandleLifecycle(): ComponentTester; - create(bootstrap: ((aurelia: Aurelia) => Promise)): Promise; + create(bootstrap: ((configure: ((aurelia: Aurelia) => Promise)) => Promise)): Promise; dispose(): any; + waitForElement(selector: string, options: any): Promise; + waitForElements(selector: string, options: any): Promise; } /** diff --git a/dist/aurelia-testing.js b/dist/aurelia-testing.js index 33a6c0f..35c5095 100644 --- a/dist/aurelia-testing.js +++ b/dist/aurelia-testing.js @@ -4,11 +4,62 @@ import {Aurelia} from 'aurelia-framework'; import {inject} from 'aurelia-dependency-injection'; import {DOM} from 'aurelia-pal'; -export const StageComponent = { - withResources(resources): ComponentTester { +/** + * Generic function to wait for something to happen. Uses polling + * @param getter: a getter function that returns anything else than `null` or an + * empty array or an empty jQuery object when the + * condition is met + * @param options: lookup options, defaults to + * `{present: true, interval: 50, timeout: 5000}` + */ +export function waitFor(getter: () => any, options: any): Promise { + // prevents infinite recursion if the request times out + let timedOut = false; + + options = Object.assign({ + present: true, + interval: 50, + timeout: 5000 + }, options); + + + function wait() { + let element = getter(); + // boolean is needed here, hence the length > 0 + let found = element !== null && (!(element instanceof NodeList) && + !element.jquery || element.length > 0); + + if (!options.present ^ found || timedOut) { + return Promise.resolve(element); + } + + return new Promise(rs => setTimeout(rs, options.interval)).then(wait); + } + + return Promise.race([ + new Promise( + (rs, rj) => setTimeout(() => { + timedOut = true; + rj(options.present ? 'Element not found' : 'Element not removed'); + }, options.timeout) + ), + wait() + ]); +} + +export function waitForDocumentElement(selector: string, options: any): Promise { + return waitFor(() => document.querySelector(selector), options); +} + +export function waitForDocumentElements(selector: string, options: any): Promise { + return waitFor(() => document.querySelectorAll(selector), options); +} + +export class StageComponent { + static withResources(resources: string | string[]): ComponentTester { return new ComponentTester().withResources(resources); } -}; +} export class ComponentTester { bind: (bindingContext: any) => void; @@ -46,7 +97,7 @@ export class ComponentTester { return this; } - create(bootstrap: (aurelia: Aurelia) => Promise): Promise { + create(bootstrap: (configure: (aurelia: Aurelia) => Promise) => Promise): Promise { return bootstrap(aurelia => { return Promise.resolve(this.configure(aurelia)).then(() => { if (this._resources) { @@ -121,6 +172,14 @@ export class ComponentTester { setTimeout(() => resolve(), 0); }); } + + waitForElement(selector: string, options: any): Promise { + return waitFor(() => this.element.querySelector(selector), options); + } + + waitForElements(selector: string, options: any): Promise { + return waitFor(() => this.element.querySelectorAll(selector), options); + } } /** diff --git a/dist/commonjs/aurelia-testing.js b/dist/commonjs/aurelia-testing.js index 95b3eaf..8b3062a 100644 --- a/dist/commonjs/aurelia-testing.js +++ b/dist/commonjs/aurelia-testing.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports.configure = exports.ComponentTester = exports.StageComponent = exports.ViewSpy = exports.CompileSpy = undefined; +exports.waitForDocumentElements = exports.waitForDocumentElement = exports.waitFor = exports.configure = exports.ComponentTester = exports.StageComponent = exports.ViewSpy = exports.CompileSpy = undefined; var _compileSpy = require('./compile-spy'); @@ -11,6 +11,8 @@ var _viewSpy = require('./view-spy'); var _componentTester = require('./component-tester'); +var _wait = require('./wait'); + function configure(config) { config.globalResources('./compile-spy', './view-spy'); } @@ -19,4 +21,7 @@ exports.CompileSpy = _compileSpy.CompileSpy; exports.ViewSpy = _viewSpy.ViewSpy; exports.StageComponent = _componentTester.StageComponent; exports.ComponentTester = _componentTester.ComponentTester; -exports.configure = configure; \ No newline at end of file +exports.configure = configure; +exports.waitFor = _wait.waitFor; +exports.waitForDocumentElement = _wait.waitForDocumentElement; +exports.waitForDocumentElements = _wait.waitForDocumentElements; \ No newline at end of file diff --git a/dist/commonjs/component-tester.js b/dist/commonjs/component-tester.js index 2ca9524..a88f95b 100644 --- a/dist/commonjs/component-tester.js +++ b/dist/commonjs/component-tester.js @@ -11,11 +11,17 @@ var _aureliaFramework = require('aurelia-framework'); -var StageComponent = exports.StageComponent = { - withResources: function withResources(resources) { - return new ComponentTester().withResources(resources); +var StageComponent = exports.StageComponent = function () { + function StageComponent() { + } -}; + + StageComponent.withResources = function withResources(resources) { + return new ComponentTester().withResources(resources); + }; + + return StageComponent; +}(); var ComponentTester = exports.ComponentTester = function () { function ComponentTester() { @@ -146,5 +152,21 @@ var ComponentTester = exports.ComponentTester = function () { }; }; + ComponentTester.prototype.waitForElement = function waitForElement(selector, options) { + var _this3 = this; + + return waitFor(function () { + return _this3.element.querySelector(selector); + }, options); + }; + + ComponentTester.prototype.waitForElements = function waitForElements(selector, options) { + var _this4 = this; + + return waitFor(function () { + return _this4.element.querySelectorAll(selector); + }, options); + }; + return ComponentTester; }(); \ No newline at end of file diff --git a/dist/commonjs/wait.js b/dist/commonjs/wait.js new file mode 100644 index 0000000..eb0799c --- /dev/null +++ b/dist/commonjs/wait.js @@ -0,0 +1,50 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.waitFor = waitFor; +exports.waitForDocumentElement = waitForDocumentElement; +exports.waitForDocumentElements = waitForDocumentElements; +function waitFor(getter, options) { + var timedOut = false; + + options = Object.assign({ + present: true, + interval: 50, + timeout: 5000 + }, options); + + function wait() { + var element = getter(); + + var found = element !== null && (!(element instanceof NodeList) && !element.jquery || element.length > 0); + + if (!options.present ^ found || timedOut) { + return Promise.resolve(element); + } + + return new Promise(function (rs) { + return setTimeout(rs, options.interval); + }).then(wait); + } + + return Promise.race([new Promise(function (rs, rj) { + return setTimeout(function () { + timedOut = true; + rj(options.present ? 'Element not found' : 'Element not removed'); + }, options.timeout); + }), wait()]); +} + +function waitForDocumentElement(selector, options) { + return waitFor(function () { + return document.querySelector(selector); + }, options); +} + +function waitForDocumentElements(selector, options) { + return waitFor(function () { + return document.querySelectorAll(selector); + }, options); +} \ No newline at end of file diff --git a/dist/es2015/aurelia-testing.js b/dist/es2015/aurelia-testing.js index 74523a8..71099be 100644 --- a/dist/es2015/aurelia-testing.js +++ b/dist/es2015/aurelia-testing.js @@ -1,9 +1,10 @@ import { CompileSpy } from './compile-spy'; import { ViewSpy } from './view-spy'; import { StageComponent, ComponentTester } from './component-tester'; +import { waitFor, waitForDocumentElement, waitForDocumentElements } from './wait'; function configure(config) { config.globalResources('./compile-spy', './view-spy'); } -export { CompileSpy, ViewSpy, StageComponent, ComponentTester, configure }; \ No newline at end of file +export { CompileSpy, ViewSpy, StageComponent, ComponentTester, configure, waitFor, waitForDocumentElement, waitForDocumentElements }; \ No newline at end of file diff --git a/dist/es2015/component-tester.js b/dist/es2015/component-tester.js index f98bb0d..acbab0f 100644 --- a/dist/es2015/component-tester.js +++ b/dist/es2015/component-tester.js @@ -1,8 +1,8 @@ import { View } from 'aurelia-templating'; import { Aurelia } from 'aurelia-framework'; -export const StageComponent = { - withResources(resources) { +export let StageComponent = class StageComponent { + static withResources(resources) { return new ComponentTester().withResources(resources); } }; @@ -107,4 +107,12 @@ export let ComponentTester = class ComponentTester { setTimeout(() => resolve(), 0); }); } + + waitForElement(selector, options) { + return waitFor(() => this.element.querySelector(selector), options); + } + + waitForElements(selector, options) { + return waitFor(() => this.element.querySelectorAll(selector), options); + } }; \ No newline at end of file diff --git a/dist/es2015/wait.js b/dist/es2015/wait.js new file mode 100644 index 0000000..1383ca7 --- /dev/null +++ b/dist/es2015/wait.js @@ -0,0 +1,35 @@ + +export function waitFor(getter, options) { + let timedOut = false; + + options = Object.assign({ + present: true, + interval: 50, + timeout: 5000 + }, options); + + function wait() { + let element = getter(); + + let found = element !== null && (!(element instanceof NodeList) && !element.jquery || element.length > 0); + + if (!options.present ^ found || timedOut) { + return Promise.resolve(element); + } + + return new Promise(rs => setTimeout(rs, options.interval)).then(wait); + } + + return Promise.race([new Promise((rs, rj) => setTimeout(() => { + timedOut = true; + rj(options.present ? 'Element not found' : 'Element not removed'); + }, options.timeout)), wait()]); +} + +export function waitForDocumentElement(selector, options) { + return waitFor(() => document.querySelector(selector), options); +} + +export function waitForDocumentElements(selector, options) { + return waitFor(() => document.querySelectorAll(selector), options); +} \ No newline at end of file diff --git a/dist/native-modules/aurelia-testing.js b/dist/native-modules/aurelia-testing.js index 74523a8..71099be 100644 --- a/dist/native-modules/aurelia-testing.js +++ b/dist/native-modules/aurelia-testing.js @@ -1,9 +1,10 @@ import { CompileSpy } from './compile-spy'; import { ViewSpy } from './view-spy'; import { StageComponent, ComponentTester } from './component-tester'; +import { waitFor, waitForDocumentElement, waitForDocumentElements } from './wait'; function configure(config) { config.globalResources('./compile-spy', './view-spy'); } -export { CompileSpy, ViewSpy, StageComponent, ComponentTester, configure }; \ No newline at end of file +export { CompileSpy, ViewSpy, StageComponent, ComponentTester, configure, waitFor, waitForDocumentElement, waitForDocumentElements }; \ No newline at end of file diff --git a/dist/native-modules/component-tester.js b/dist/native-modules/component-tester.js index 09cb0fc..17ebfe4 100644 --- a/dist/native-modules/component-tester.js +++ b/dist/native-modules/component-tester.js @@ -3,11 +3,17 @@ import { View } from 'aurelia-templating'; import { Aurelia } from 'aurelia-framework'; -export var StageComponent = { - withResources: function withResources(resources) { - return new ComponentTester().withResources(resources); +export var StageComponent = function () { + function StageComponent() { + } -}; + + StageComponent.withResources = function withResources(resources) { + return new ComponentTester().withResources(resources); + }; + + return StageComponent; +}(); export var ComponentTester = function () { function ComponentTester() { @@ -138,5 +144,21 @@ export var ComponentTester = function () { }; }; + ComponentTester.prototype.waitForElement = function waitForElement(selector, options) { + var _this3 = this; + + return waitFor(function () { + return _this3.element.querySelector(selector); + }, options); + }; + + ComponentTester.prototype.waitForElements = function waitForElements(selector, options) { + var _this4 = this; + + return waitFor(function () { + return _this4.element.querySelectorAll(selector); + }, options); + }; + return ComponentTester; }(); \ No newline at end of file diff --git a/dist/native-modules/wait.js b/dist/native-modules/wait.js new file mode 100644 index 0000000..04871bb --- /dev/null +++ b/dist/native-modules/wait.js @@ -0,0 +1,43 @@ + +export function waitFor(getter, options) { + var timedOut = false; + + options = Object.assign({ + present: true, + interval: 50, + timeout: 5000 + }, options); + + function wait() { + var element = getter(); + + var found = element !== null && (!(element instanceof NodeList) && !element.jquery || element.length > 0); + + if (!options.present ^ found || timedOut) { + return Promise.resolve(element); + } + + return new Promise(function (rs) { + return setTimeout(rs, options.interval); + }).then(wait); + } + + return Promise.race([new Promise(function (rs, rj) { + return setTimeout(function () { + timedOut = true; + rj(options.present ? 'Element not found' : 'Element not removed'); + }, options.timeout); + }), wait()]); +} + +export function waitForDocumentElement(selector, options) { + return waitFor(function () { + return document.querySelector(selector); + }, options); +} + +export function waitForDocumentElements(selector, options) { + return waitFor(function () { + return document.querySelectorAll(selector); + }, options); +} \ No newline at end of file diff --git a/dist/system/aurelia-testing.js b/dist/system/aurelia-testing.js index 2945f7a..942cd38 100644 --- a/dist/system/aurelia-testing.js +++ b/dist/system/aurelia-testing.js @@ -1,9 +1,9 @@ 'use strict'; -System.register(['./compile-spy', './view-spy', './component-tester'], function (_export, _context) { +System.register(['./compile-spy', './view-spy', './component-tester', './wait'], function (_export, _context) { "use strict"; - var CompileSpy, ViewSpy, StageComponent, ComponentTester; + var CompileSpy, ViewSpy, StageComponent, ComponentTester, waitFor, waitForDocumentElement, waitForDocumentElements; function configure(config) { @@ -18,6 +18,10 @@ System.register(['./compile-spy', './view-spy', './component-tester'], function }, function (_componentTester) { StageComponent = _componentTester.StageComponent; ComponentTester = _componentTester.ComponentTester; + }, function (_wait) { + waitFor = _wait.waitFor; + waitForDocumentElement = _wait.waitForDocumentElement; + waitForDocumentElements = _wait.waitForDocumentElements; }], execute: function () { _export('CompileSpy', CompileSpy); @@ -29,6 +33,12 @@ System.register(['./compile-spy', './view-spy', './component-tester'], function _export('ComponentTester', ComponentTester); _export('configure', configure); + + _export('waitFor', waitFor); + + _export('waitForDocumentElement', waitForDocumentElement); + + _export('waitForDocumentElements', waitForDocumentElements); } }; }); \ No newline at end of file diff --git a/dist/system/component-tester.js b/dist/system/component-tester.js index 17f2701..89f0242 100644 --- a/dist/system/component-tester.js +++ b/dist/system/component-tester.js @@ -14,11 +14,17 @@ System.register(['aurelia-templating', 'aurelia-framework'], function (_export, Aurelia = _aureliaFramework.Aurelia; }], execute: function () { - _export('StageComponent', StageComponent = { - withResources: function withResources(resources) { - return new ComponentTester().withResources(resources); + _export('StageComponent', StageComponent = function () { + function StageComponent() { + } - }); + + StageComponent.withResources = function withResources(resources) { + return new ComponentTester().withResources(resources); + }; + + return StageComponent; + }()); _export('StageComponent', StageComponent); @@ -151,6 +157,22 @@ System.register(['aurelia-templating', 'aurelia-framework'], function (_export, }; }; + ComponentTester.prototype.waitForElement = function waitForElement(selector, options) { + var _this3 = this; + + return waitFor(function () { + return _this3.element.querySelector(selector); + }, options); + }; + + ComponentTester.prototype.waitForElements = function waitForElements(selector, options) { + var _this4 = this; + + return waitFor(function () { + return _this4.element.querySelectorAll(selector); + }, options); + }; + return ComponentTester; }()); diff --git a/dist/system/wait.js b/dist/system/wait.js new file mode 100644 index 0000000..39b37b8 --- /dev/null +++ b/dist/system/wait.js @@ -0,0 +1,59 @@ +'use strict'; + +System.register([], function (_export, _context) { + "use strict"; + + function waitFor(getter, options) { + var timedOut = false; + + options = Object.assign({ + present: true, + interval: 50, + timeout: 5000 + }, options); + + function wait() { + var element = getter(); + + var found = element !== null && (!(element instanceof NodeList) && !element.jquery || element.length > 0); + + if (!options.present ^ found || timedOut) { + return Promise.resolve(element); + } + + return new Promise(function (rs) { + return setTimeout(rs, options.interval); + }).then(wait); + } + + return Promise.race([new Promise(function (rs, rj) { + return setTimeout(function () { + timedOut = true; + rj(options.present ? 'Element not found' : 'Element not removed'); + }, options.timeout); + }), wait()]); + } + + _export('waitFor', waitFor); + + function waitForDocumentElement(selector, options) { + return waitFor(function () { + return document.querySelector(selector); + }, options); + } + + _export('waitForDocumentElement', waitForDocumentElement); + + function waitForDocumentElements(selector, options) { + return waitFor(function () { + return document.querySelectorAll(selector); + }, options); + } + + _export('waitForDocumentElements', waitForDocumentElements); + + return { + setters: [], + execute: function () {} + }; +}); \ No newline at end of file diff --git a/dist/temp/aurelia-testing.js b/dist/temp/aurelia-testing.js index 56ae7f1..4556480 100644 --- a/dist/temp/aurelia-testing.js +++ b/dist/temp/aurelia-testing.js @@ -7,6 +7,10 @@ exports.CompileSpy = exports.ViewSpy = exports.ComponentTester = exports.StageCo var _dec, _class2, _dec2, _dec3, _class3; +exports.waitFor = waitFor; +exports.waitForDocumentElement = waitForDocumentElement; +exports.waitForDocumentElements = waitForDocumentElements; + var _aureliaLogging = require('aurelia-logging'); var LogManager = _interopRequireWildcard(_aureliaLogging); @@ -23,11 +27,60 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var StageComponent = exports.StageComponent = { - withResources: function withResources(resources) { - return new ComponentTester().withResources(resources); +function waitFor(getter, options) { + var timedOut = false; + + options = Object.assign({ + present: true, + interval: 50, + timeout: 5000 + }, options); + + function wait() { + var element = getter(); + + var found = element !== null && (!(element instanceof NodeList) && !element.jquery || element.length > 0); + + if (!options.present ^ found || timedOut) { + return Promise.resolve(element); + } + + return new Promise(function (rs) { + return setTimeout(rs, options.interval); + }).then(wait); } -}; + + return Promise.race([new Promise(function (rs, rj) { + return setTimeout(function () { + timedOut = true; + rj(options.present ? 'Element not found' : 'Element not removed'); + }, options.timeout); + }), wait()]); +} + +function waitForDocumentElement(selector, options) { + return waitFor(function () { + return document.querySelector(selector); + }, options); +} + +function waitForDocumentElements(selector, options) { + return waitFor(function () { + return document.querySelectorAll(selector); + }, options); +} + +var StageComponent = exports.StageComponent = function () { + function StageComponent() { + _classCallCheck(this, StageComponent); + } + + StageComponent.withResources = function withResources(resources) { + return new ComponentTester().withResources(resources); + }; + + return StageComponent; +}(); var ComponentTester = exports.ComponentTester = function () { function ComponentTester() { @@ -158,6 +211,22 @@ var ComponentTester = exports.ComponentTester = function () { }; }; + ComponentTester.prototype.waitForElement = function waitForElement(selector, options) { + var _this3 = this; + + return waitFor(function () { + return _this3.element.querySelector(selector); + }, options); + }; + + ComponentTester.prototype.waitForElements = function waitForElements(selector, options) { + var _this4 = this; + + return waitFor(function () { + return _this4.element.querySelectorAll(selector); + }, options); + }; + return ComponentTester; }(); diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 304d824..0e4f7b0 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,3 +1,18 @@ + +# [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) + + +### Bug Fixes + +* **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) + + +### Features + +* **component-tester:** add waitForElement method and options ([#32](https://github.com/aurelia/testing/issues/32)) ([65eb382](https://github.com/aurelia/testing/commit/65eb382)) + + + # [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) diff --git a/doc/api.json b/doc/api.json index b1c42d2..47c8bdf 100644 --- a/doc/api.json +++ b/doc/api.json @@ -1 +1 @@ -{"name":"aurelia-testing","children":[{"id":56,"name":"CompileSpy","kind":128,"kindString":"Class","flags":{"isExported":true},"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":57,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"comment":{"shortText":"Creates and instanse of CompileSpy."},"signatures":[{"id":58,"name":"new CompileSpy","kind":16384,"kindString":"Constructor signature","flags":{},"comment":{"shortText":"Creates and instanse of CompileSpy."},"parameters":[{"id":59,"name":"element","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"comment":{"shortText":"target element on where attribute is placed on."},"type":{"type":"instrinct","name":"any"}},{"id":60,"name":"instruction","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"comment":{"shortText":"instructions for how the target element should be enhanced.\n"},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"reference","name":"CompileSpy","id":56}}]}],"groups":[{"title":"Constructors","kind":512,"children":[57]}]},{"id":2,"name":"ComponentTester","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":7,"name":"attached","kind":1024,"kindString":"Property","flags":{"isExported":true},"type":{"type":"reflection","declaration":{"id":8,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":9,"name":"__call","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"void"}}]}}},{"id":3,"name":"bind","kind":1024,"kindString":"Property","flags":{"isExported":true},"type":{"type":"reflection","declaration":{"id":4,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":5,"name":"__call","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":6,"name":"bindingContext","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"instrinct","name":"void"}}]}}},{"id":15,"name":"configure","kind":1024,"kindString":"Property","flags":{"isExported":true},"type":{"type":"instrinct","name":"any"}},{"id":13,"name":"element","kind":1024,"kindString":"Property","flags":{"isExported":true},"type":{"type":"reference","name":"Element"}},{"id":10,"name":"unbind","kind":1024,"kindString":"Property","flags":{"isExported":true},"type":{"type":"reflection","declaration":{"id":11,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":12,"name":"__call","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"void"}}]}}},{"id":14,"name":"viewModel","kind":1024,"kindString":"Property","flags":{"isExported":true},"type":{"type":"instrinct","name":"any"}},{"id":16,"name":"bootstrap","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":17,"name":"bootstrap","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":18,"name":"configure","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":19,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":20,"name":"__call","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":21,"name":"aurelia","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"Aurelia"}}],"type":{"type":"instrinct","name":"void"}}]}}}],"type":{"type":"instrinct","name":"any"}}]},{"id":28,"name":"boundTo","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":29,"name":"boundTo","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":30,"name":"bindingContext","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"reference","name":"ComponentTester","id":2}}]},{"id":33,"name":"create","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":34,"name":"create","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":35,"name":"bootstrap","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":36,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":37,"name":"__call","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":38,"name":"aurelia","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"Aurelia"}}],"type":{"type":"reference","name":"Promise","typeArguments":[{"type":"instrinct","name":"void"}]}}]}}}],"type":{"type":"reference","name":"Promise","typeArguments":[{"type":"instrinct","name":"void"}]}}]},{"id":39,"name":"dispose","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":40,"name":"dispose","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"any"}}]},{"id":25,"name":"inView","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":26,"name":"inView","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":27,"name":"html","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"reference","name":"ComponentTester","id":2}}]},{"id":31,"name":"manuallyHandleLifecycle","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":32,"name":"manuallyHandleLifecycle","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"reference","name":"ComponentTester","id":2}}]},{"id":22,"name":"withResources","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":23,"name":"withResources","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":24,"name":"resources","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"union","types":[{"type":"instrinct","name":"string"},{"type":"instrinct","isArray":true,"name":"string"}]}}],"type":{"type":"reference","name":"ComponentTester","id":2}}]}],"groups":[{"title":"Properties","kind":1024,"children":[7,3,15,13,10,14]},{"title":"Methods","kind":2048,"children":[16,28,33,39,25,31,22]}]},{"id":41,"name":"ViewSpy","kind":128,"kindString":"Class","flags":{"isExported":true},"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":42,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"comment":{"shortText":"Creates a new instance of ViewSpy."},"signatures":[{"id":43,"name":"new ViewSpy","kind":16384,"kindString":"Constructor signature","flags":{},"comment":{"shortText":"Creates a new instance of ViewSpy."},"type":{"type":"reference","name":"ViewSpy","id":41}}]},{"id":50,"name":"attached","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":51,"name":"attached","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Invoked when the target element is attached to the DOM."},"type":{"type":"instrinct","name":"any"}}]},{"id":47,"name":"bind","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":48,"name":"bind","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Invoked when the target view is bound."},"parameters":[{"id":49,"name":"bindingContext","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"comment":{"text":"The target view's binding context.\n"},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"instrinct","name":"any"}}]},{"id":44,"name":"created","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":45,"name":"created","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Invoked when the target view is created."},"parameters":[{"id":46,"name":"view","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"comment":{"text":"The target view.\n"},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"instrinct","name":"any"}}]},{"id":52,"name":"detached","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":53,"name":"detached","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Invoked when the target element is detached from the DOM."},"type":{"type":"instrinct","name":"any"}}]},{"id":54,"name":"unbind","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":55,"name":"unbind","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Invoked when the target element is unbound."},"type":{"type":"instrinct","name":"any"}}]}],"groups":[{"title":"Constructors","kind":512,"children":[42]},{"title":"Methods","kind":2048,"children":[50,47,44,52,54]}]},{"id":61,"name":"StageComponent","kind":32,"kindString":"Variable","flags":{"isExported":true},"type":{"type":"instrinct","name":"any"}}],"groups":[{"title":"Classes","kind":128,"children":[56,2,41]},{"title":"Variables","kind":32,"children":[61]}]} \ No newline at end of file +{"name":"aurelia-testing","children":[{"id":71,"name":"CompileSpy","kind":128,"kindString":"Class","flags":{"isExported":true},"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":72,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"comment":{"shortText":"Creates and instanse of CompileSpy."},"signatures":[{"id":73,"name":"new CompileSpy","kind":16384,"kindString":"Constructor signature","flags":{},"comment":{"shortText":"Creates and instanse of CompileSpy."},"parameters":[{"id":74,"name":"element","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"comment":{"shortText":"target element on where attribute is placed on."},"type":{"type":"instrinct","name":"any"}},{"id":75,"name":"instruction","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"comment":{"shortText":"instructions for how the target element should be enhanced.\n"},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"reference","name":"CompileSpy","id":71}}]}],"groups":[{"title":"Constructors","kind":512,"children":[72]}]},{"id":6,"name":"ComponentTester","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":11,"name":"attached","kind":1024,"kindString":"Property","flags":{"isExported":true},"type":{"type":"reflection","declaration":{"id":12,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":13,"name":"__call","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"void"}}]}}},{"id":7,"name":"bind","kind":1024,"kindString":"Property","flags":{"isExported":true},"type":{"type":"reflection","declaration":{"id":8,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":9,"name":"__call","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":10,"name":"bindingContext","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"instrinct","name":"void"}}]}}},{"id":19,"name":"configure","kind":1024,"kindString":"Property","flags":{"isExported":true},"type":{"type":"instrinct","name":"any"}},{"id":17,"name":"element","kind":1024,"kindString":"Property","flags":{"isExported":true},"type":{"type":"reference","name":"Element"}},{"id":14,"name":"unbind","kind":1024,"kindString":"Property","flags":{"isExported":true},"type":{"type":"reflection","declaration":{"id":15,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":16,"name":"__call","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"void"}}]}}},{"id":18,"name":"viewModel","kind":1024,"kindString":"Property","flags":{"isExported":true},"type":{"type":"instrinct","name":"any"}},{"id":20,"name":"bootstrap","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":21,"name":"bootstrap","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":22,"name":"configure","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":23,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":24,"name":"__call","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":25,"name":"aurelia","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"Aurelia"}}],"type":{"type":"instrinct","name":"void"}}]}}}],"type":{"type":"instrinct","name":"any"}}]},{"id":32,"name":"boundTo","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":33,"name":"boundTo","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":34,"name":"bindingContext","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"reference","name":"ComponentTester","id":6}}]},{"id":37,"name":"create","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":38,"name":"create","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":39,"name":"bootstrap","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":40,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":41,"name":"__call","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":42,"name":"configure","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":43,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":44,"name":"__call","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":45,"name":"aurelia","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"Aurelia"}}],"type":{"type":"reference","name":"Promise","typeArguments":[{"type":"instrinct","name":"void"}]}}]}}}],"type":{"type":"reference","name":"Promise","typeArguments":[{"type":"instrinct","name":"void"}]}}]}}}],"type":{"type":"reference","name":"Promise","typeArguments":[{"type":"instrinct","name":"void"}]}}]},{"id":46,"name":"dispose","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":47,"name":"dispose","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"any"}}]},{"id":29,"name":"inView","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":30,"name":"inView","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":31,"name":"html","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"reference","name":"ComponentTester","id":6}}]},{"id":35,"name":"manuallyHandleLifecycle","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":36,"name":"manuallyHandleLifecycle","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"reference","name":"ComponentTester","id":6}}]},{"id":48,"name":"waitForElement","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":49,"name":"waitForElement","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":50,"name":"selector","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"string"}},{"id":51,"name":"options","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"reference","name":"Promise","typeArguments":[{"type":"reference","name":"Element"}]}}]},{"id":52,"name":"waitForElements","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":53,"name":"waitForElements","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":54,"name":"selector","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"string"}},{"id":55,"name":"options","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"reference","name":"Promise","typeArguments":[{"type":"reference","name":"Element"}]}}]},{"id":26,"name":"withResources","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":27,"name":"withResources","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":28,"name":"resources","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"union","types":[{"type":"instrinct","name":"string"},{"type":"instrinct","isArray":true,"name":"string"}]}}],"type":{"type":"reference","name":"ComponentTester","id":6}}]}],"groups":[{"title":"Properties","kind":1024,"children":[11,7,19,17,14,18]},{"title":"Methods","kind":2048,"children":[20,32,37,46,29,35,48,52,26]}]},{"id":2,"name":"StageComponent","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":3,"name":"withResources","kind":2048,"kindString":"Method","flags":{"isStatic":true,"isExported":true},"signatures":[{"id":4,"name":"withResources","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":5,"name":"resources","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"union","types":[{"type":"instrinct","name":"string"},{"type":"instrinct","isArray":true,"name":"string"}]}}],"type":{"type":"reference","name":"ComponentTester","id":6}}]}],"groups":[{"title":"Methods","kind":2048,"children":[3]}]},{"id":56,"name":"ViewSpy","kind":128,"kindString":"Class","flags":{"isExported":true},"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":57,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"comment":{"shortText":"Creates a new instance of ViewSpy."},"signatures":[{"id":58,"name":"new ViewSpy","kind":16384,"kindString":"Constructor signature","flags":{},"comment":{"shortText":"Creates a new instance of ViewSpy."},"type":{"type":"reference","name":"ViewSpy","id":56}}]},{"id":65,"name":"attached","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":66,"name":"attached","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Invoked when the target element is attached to the DOM."},"type":{"type":"instrinct","name":"any"}}]},{"id":62,"name":"bind","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":63,"name":"bind","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Invoked when the target view is bound."},"parameters":[{"id":64,"name":"bindingContext","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"comment":{"text":"The target view's binding context.\n"},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"instrinct","name":"any"}}]},{"id":59,"name":"created","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":60,"name":"created","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Invoked when the target view is created."},"parameters":[{"id":61,"name":"view","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"comment":{"text":"The target view.\n"},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"instrinct","name":"any"}}]},{"id":67,"name":"detached","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":68,"name":"detached","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Invoked when the target element is detached from the DOM."},"type":{"type":"instrinct","name":"any"}}]},{"id":69,"name":"unbind","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":70,"name":"unbind","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Invoked when the target element is unbound."},"type":{"type":"instrinct","name":"any"}}]}],"groups":[{"title":"Constructors","kind":512,"children":[57]},{"title":"Methods","kind":2048,"children":[65,62,59,67,69]}]},{"id":76,"name":"waitFor","kind":64,"kindString":"Function","flags":{"isExported":true},"signatures":[{"id":77,"name":"waitFor","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Generic function to wait for something to happen. Uses polling"},"parameters":[{"id":78,"name":"getter","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":79,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":80,"name":"__call","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"any"}}]}}},{"id":81,"name":"options","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"reference","name":"Promise","typeArguments":[{"type":"instrinct","name":"any"}]}}]},{"id":82,"name":"waitForDocumentElement","kind":64,"kindString":"Function","flags":{"isExported":true},"signatures":[{"id":83,"name":"waitForDocumentElement","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":84,"name":"selector","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"string"}},{"id":85,"name":"options","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"reference","name":"Promise","typeArguments":[{"type":"reference","name":"Element"}]}}]},{"id":86,"name":"waitForDocumentElements","kind":64,"kindString":"Function","flags":{"isExported":true},"signatures":[{"id":87,"name":"waitForDocumentElements","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":88,"name":"selector","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"string"}},{"id":89,"name":"options","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"reference","name":"Promise","typeArguments":[{"type":"reference","name":"Element"}]}}]}],"groups":[{"title":"Classes","kind":128,"children":[71,6,2,56]},{"title":"Functions","kind":64,"children":[76,82,86]}]} \ No newline at end of file diff --git a/package.json b/package.json index 972f097..9de77ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-testing", - "version": "1.0.0-beta.2.0.1", + "version": "1.0.0-beta.3.0.0", "description": "A collection of helpers for testing Aurelia apps and components.", "keywords": [ "aurelia",