DefinitelyTyped/types/ember-testing-helpers/ember-testing-helpers-tests.ts
Chris Krycho dfa4555106 Update Ember, RSVP, and Ember testing helpers. (#20301)
* Update RSVP to 4.0, to implement PromiseLike<T>.

- RSVP Promises can now be used with `async` and `await`.
- RSVP types now match what is in RSVP 4.0.

* Update ember-testing-helpers for fixed RSVP.

* Ember.js: correctly represent most of the framework.

- Capture the actual behavior of most of the framework, including computed
  properties, custom getters and setters and the custom Object model more
  generally, prototype extension via `.extend`, and the mixin pattern.
- Support the new modules API alongside the global API.
- Add extensive tests.
- Update inline documentation.
- Use the new, async/await compatible RSVP definitions.

* Ember/RSVP: drop .prettierrc files.

* Drop types/rsvp/assert.ts -- stick to just rsvp-test.ts.

* Fix ember-testing-helpers-tests on top of module itself.

* Fix RSVP import in ember-testing-helpers.

* Fix 'typeRoots', set ember-testing-helpers to use TS 2.4.

* Fix missing 'types' compiler option.

* Fix errors caught by dtslint.

* A few more tslint tweaks.

* Fix account link in ember-testing-helpers authorship.

* Disable strictFunctionTypes for Ember, RSVP.

* fix array.reduce signature conflict in ts@next
2017-10-13 03:13:17 -07:00

82 lines
2.0 KiB
TypeScript

import RSVP from 'rsvp';
function testAndThen() {
const result: RSVP.Promise<string> = andThen(() => 'some string');
result.then(s => s.length);
}
function testClick() {
const result: RSVP.Promise<void> = click('someString');
result.then(() => {});
}
function testCurrentPath() {
const path = currentPath();
const chars = path.split('');
}
function testCurrentRouteName() {
const routeName = currentRouteName();
const isIndex = routeName === 'index';
}
function testCurrentURL() {
const url = currentURL();
const isIndex = url.match(/^\/$/);
}
function testFillIn() {
const textResult = fillIn('.foo', 'waffles');
textResult.then(() => true);
const contextResult = fillIn('.bar', {}, 'pancakes');
contextResult.catch((reason: any) => false);
}
function testFind() {
const found = find('#quux');
found.addClass('has-ducks');
const foundInAContext = find('#baz', {});
foundInAContext.removeClass('can-cluck');
}
function testFindWithAssert() {
const found = findWithAssert('#quux');
found.addClass('has-ducks');
const foundInAContext = findWithAssert('#baz', {});
foundInAContext.removeClass('can-cluck');
}
function testKeyEvent() {
keyEvent('.some-button', 'keydown', 11).then(() => 11);
keyEvent('.some-button', 'keypress', 101).then(() => 101);
keyEvent('.some-button', 'keyup', 1001).then(() => 1001);
}
function testPauseTest() {
pauseTest().finally(() => {
const foo = 'fighters';
});
}
function testResumeTest() {
resumeTest();
}
function testTriggerEvent() {
triggerEvent('.something', {}, 'click', {}).then(() => 'yay');
triggerEvent('.something', 'mousedown').then(() => 'no');
triggerEvent('.something', {}, 'fetch').then(() => 'huzzah');
triggerEvent('.something', 'keydown').then(() => 'whomp whomp');
}
function testVisit() {
visit('some/url').then(() => {});
}
function testWait() {
const waited = wait('whatever');
waited.then((s: string) => s.length);
}