ember-qunit: Add setupTest and setupRenderingTest

This commit is contained in:
Frank Tan
2017-12-22 18:21:38 -05:00
parent 626f4832f9
commit d76f2715f9
2 changed files with 61 additions and 0 deletions
+24
View File
@@ -8,6 +8,8 @@ import {
moduleForModel,
moduleForComponent,
setResolver,
setupRenderingTest,
setupTest,
} from 'ember-qunit';
moduleForComponent('x-foo', {
@@ -113,3 +115,25 @@ test('It can calculate the result', function(assert) {
skip('disabled test');
skip('disabled test', function(assert) { });
// https://github.com/emberjs/rfcs/blob/master/text/0232-simplify-qunit-testing-api.md#qunit-nested-modules-api
QUnit.module('some description', function(hooks) {
hooks.before(() => {});
hooks.beforeEach(() => {});
hooks.afterEach(() => {});
hooks.after(() => {});
QUnit.test('it blends', function(assert) {
assert.ok(true, 'of course!');
});
});
// http://rwjblue.com/2017/10/23/ember-qunit-simplication/#setuprenderingtest
module('x-foo', function(hooks) {
setupRenderingTest(hooks);
});
// http://rwjblue.com/2017/10/23/ember-qunit-simplication/#setuprenderingtest
module('foo service', function(hooks) {
setupTest(hooks);
});
+37
View File
@@ -1,6 +1,7 @@
// Type definitions for ember-qunit 3.0
// Project: https://github.com/emberjs/ember-qunit#readme
// Definitions by: Derek Wickern <https://github.com/dwickern>
// Frank Tan <https://github.com/tansongyang>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
@@ -43,6 +44,42 @@ declare module 'ember-qunit' {
*/
export function setResolver(resolver: Ember.Resolver): void;
/**
* Sets up tests that need to render snippets of templates.
*
* The setupRenderingTest method is used for tests that need to render
* snippets of templates. It is also invoked in the callback scope of a
* QUnit module (aka "nested module").
*
* Once invoked, all subsequent hooks.beforeEach and test invocations will
* have access to the following:
* * All of the methods / properties listed for `setupTest`
* * this.render(...) - Renders the provided template snippet returning a
* promise that resolves once rendering has completed
* * An importable render function that de-sugars into this.render will be
* the default output of blueprints
* * this.element - Returns the native DOM element representing the element
* that was rendered via this.render
* * this.$(...) - When jQuery is present, executes a jQuery selector with
* the current this.element as its root
*/
export function setupRenderingTest(hooks: NestedHooks): void;
/**
* Sets up tests that do not need to render snippets of templates.
*
* The `setupTest` method is used for all types of tests except for those
* that need to render snippets of templates. It is invoked in the callback
* scope of a QUnit module (aka "nested module").
*
* Once invoked, all subsequent hooks.beforeEach and test invocations will
* have access to the following:
* * this.owner - This exposes the standard "owner API" for the test environment.
* * this.set / this.setProperties - Allows setting values on the test context.
* * this.get / this.getProperties - Retrieves values from the test context.
*/
export function setupTest(hooks: NestedHooks): void;
export class QUnitAdapter extends Ember.Test.Adapter {}
export { module, test, skip, only, todo } from 'qunit';