本文整理汇总了TypeScript中ember-qunit.moduleFor函数的典型用法代码示例。如果您正苦于以下问题:TypeScript moduleFor函数的具体用法?TypeScript moduleFor怎么用?TypeScript moduleFor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了moduleFor函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: moduleFor
import { later } from '@ember/runloop';
import { moduleFor, test } from 'ember-qunit';
moduleFor('service:resize', 'Unit | Service | resize', {
// Specify the other units that are required for this test.
// needs: ['service:foo']
});
test('it fires "didResize" when the window is resized', function(assert) {
const service = this.subject({
heightSensitive: true,
widthSensitive: false,
});
let didResizeCallCount = 0;
service.on('didResize', () => {
didResizeCallCount++;
});
const evt = new Event('resize');
window.dispatchEvent(evt);
assert.equal(didResizeCallCount, 0, 'didResize called 0 time on event firing');
service.incrementProperty('_oldHeight', -20);
window.dispatchEvent(evt);
assert.equal(didResizeCallCount, 1, 'didResize called 1 time on event firing');
service.set('heightSensitive', false);
service.incrementProperty('_oldHeight', -20);
window.dispatchEvent(evt);
assert.equal(didResizeCallCount, 1, 'didResize shouldn\'t be called again if heightSensitive is false');
示例2: moduleForComponent
import { test, skip, moduleFor, moduleForModel, moduleForComponent, setResolver } from 'ember-qunit';
moduleForComponent('x-foo', {
integration: true
});
moduleForComponent('x-foo', {
unit: true,
needs: ['helper:pluralize-string']
});
moduleForModel('user', {
needs: ['model:child']
});
moduleFor('controller:home');
moduleFor('component:x-foo', 'Some description');
moduleFor('component:x-foo', 'TestModule callbacks', {
beforeSetup() {
},
beforeEach(assert) {
this.registry.register('helper:i18n', {});
this.register('service:i18n', {});
this.inject.service('i18n');
this.inject.service('i18n', { as: 'i18n' });
this.factory('object:user').create();
assert.ok(true);
},