Skip to content

Commit

Permalink
chore(all): prepare release 1.0.0-beta.3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Mar 3, 2017
1 parent 01036e7 commit f2be4c2
Show file tree
Hide file tree
Showing 23 changed files with 615 additions and 39 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
62 changes: 62 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@ System.config({
"aurelia-pal-browser": "npm:[email protected]",
"aurelia-polyfills": "npm:[email protected]",
"aurelia-templating": "npm:[email protected]",
"babel": "npm:[email protected]",
"babel-runtime": "npm:[email protected]",
"core-js": "npm:[email protected]",
"github:jspm/[email protected]": {
"assert": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"buffer": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"path-browserify": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"process": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"util": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"vm-browserify": "npm:[email protected]"
},
"npm:[email protected]": {
"assert": "github:jspm/[email protected]",
"buffer": "github:jspm/[email protected]",
"process": "github:jspm/[email protected]",
"util": "npm:[email protected]"
},
"npm:[email protected]": {
"aurelia-logging": "npm:[email protected]",
"aurelia-metadata": "npm:[email protected]",
Expand Down Expand Up @@ -127,6 +154,41 @@ System.config({
"aurelia-pal": "npm:[email protected]",
"aurelia-path": "npm:[email protected]",
"aurelia-task-queue": "npm:[email protected]"
},
"npm:[email protected]": {
"process": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"base64-js": "npm:[email protected]",
"child_process": "github:jspm/[email protected]",
"fs": "github:jspm/[email protected]",
"ieee754": "npm:[email protected]",
"isarray": "npm:[email protected]",
"process": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"fs": "github:jspm/[email protected]",
"path": "github:jspm/[email protected]",
"process": "github:jspm/[email protected]",
"systemjs-json": "github:systemjs/[email protected]"
},
"npm:[email protected]": {
"util": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"process": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"assert": "github:jspm/[email protected]",
"fs": "github:jspm/[email protected]",
"vm": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"inherits": "npm:[email protected]",
"process": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"indexof": "npm:[email protected]"
}
}
});
7 changes: 5 additions & 2 deletions dist/amd/aurelia-testing.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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;
});
30 changes: 26 additions & 4 deletions dist/amd/component-tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
}();
});
52 changes: 52 additions & 0 deletions dist/amd/wait.js
Original file line number Diff line number Diff line change
@@ -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);
}
});
20 changes: 18 additions & 2 deletions dist/aurelia-testing.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>;
export declare function waitForDocumentElement(selector: string, options: any): Promise<Element>;
export declare function waitForDocumentElements(selector: string, options: any): Promise<Element>;
export declare class StageComponent {
static withResources(resources: string | string[]): ComponentTester;
}
export declare class ComponentTester {
bind: ((bindingContext: any) => void);
attached: (() => void);
Expand All @@ -26,8 +40,10 @@ export declare class ComponentTester {
inView(html: string): ComponentTester;
boundTo(bindingContext: any): ComponentTester;
manuallyHandleLifecycle(): ComponentTester;
create(bootstrap: ((aurelia: Aurelia) => Promise<void>)): Promise<void>;
create(bootstrap: ((configure: ((aurelia: Aurelia) => Promise<void>)) => Promise<void>)): Promise<void>;
dispose(): any;
waitForElement(selector: string, options: any): Promise<Element>;
waitForElements(selector: string, options: any): Promise<Element>;
}

/**
Expand Down
67 changes: 63 additions & 4 deletions dist/aurelia-testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> {
// 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<Element> {
return waitFor(() => document.querySelector(selector), options);
}

export function waitForDocumentElements(selector: string, options: any): Promise<Element> {
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;
Expand Down Expand Up @@ -46,7 +97,7 @@ export class ComponentTester {
return this;
}

create(bootstrap: (aurelia: Aurelia) => Promise<void>): Promise<void> {
create(bootstrap: (configure: (aurelia: Aurelia) => Promise<void>) => Promise<void>): Promise<void> {
return bootstrap(aurelia => {
return Promise.resolve(this.configure(aurelia)).then(() => {
if (this._resources) {
Expand Down Expand Up @@ -121,6 +172,14 @@ export class ComponentTester {
setTimeout(() => resolve(), 0);
});
}

waitForElement(selector: string, options: any): Promise<Element> {
return waitFor(() => this.element.querySelector(selector), options);
}

waitForElements(selector: string, options: any): Promise<Element> {
return waitFor(() => this.element.querySelectorAll(selector), options);
}
}

/**
Expand Down
9 changes: 7 additions & 2 deletions dist/commonjs/aurelia-testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
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');

var _viewSpy = require('./view-spy');

var _componentTester = require('./component-tester');

var _wait = require('./wait');

function configure(config) {
config.globalResources('./compile-spy', './view-spy');
}
Expand All @@ -19,4 +21,7 @@ exports.CompileSpy = _compileSpy.CompileSpy;
exports.ViewSpy = _viewSpy.ViewSpy;
exports.StageComponent = _componentTester.StageComponent;
exports.ComponentTester = _componentTester.ComponentTester;
exports.configure = configure;
exports.configure = configure;
exports.waitFor = _wait.waitFor;
exports.waitForDocumentElement = _wait.waitForDocumentElement;
exports.waitForDocumentElements = _wait.waitForDocumentElements;
Loading

0 comments on commit f2be4c2

Please sign in to comment.