本文整理匯總了TypeScript中@ember/test-helpers.find函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript find函數的具體用法?TypeScript find怎麽用?TypeScript find使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了find函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('property rendering', async function(assert) {
const time = new Date().getTime();
const actor = 'John Appleseed';
const title = 'Last Modified';
this.set('time', time);
this.set('actor', actor);
this.set('title', title);
await render(hbs`{{last-saved-by time=time actor=actor}}`);
assert.ok(this.element.textContent!.includes(moment(time).fromNow()), 'it shows the last saved time from now');
assert.ok(this.element.textContent!.includes(actor), 'it shows the actor attribute');
await render(hbs`{{last-saved-by time=time title=title}}`);
assert.ok(this.element.textContent!.includes('Last Modified'), 'it shows the passed in title');
assert.ok(!this.element.textContent!.includes('Last Saved:'), 'it does not show the default title');
await render(hbs`
{{#last-saved-by time=time title=title actor=actor as |ls|}}
<div class="yielded-title">{{ls.title}}</div>
<div class="yielded-actor">{{ls.actor}}</div>
{{/last-saved-by}}
`);
assert.equal(find('.yielded-title')!.textContent!.trim(), title, 'block usage yields the title');
assert.equal(find('.yielded-actor')!.textContent!.trim(), actor, 'block usage yields the actor');
});
示例2: test
test('DOM interactions', async () => {
await render(hbs`<div class="message">Hello, world</div>`);
await click('.message');
await doubleClick('.message');
await tap('.message');
await focus('.message');
await blur('.message');
await triggerEvent('.message', 'custom-event');
await triggerKeyEvent('.message', 'keydown', 'Enter', { ctrlKey: true });
await fillIn('.message', 'content');
const messageElement = find('.message')!;
await click(messageElement);
await doubleClick(messageElement);
await tap(messageElement);
await focus(messageElement);
await blur(messageElement);
await triggerEvent(messageElement, 'custom-event');
await triggerKeyEvent(messageElement, 'keydown', 'Enter', { ctrlKey: true });
await fillIn(messageElement, 'content');
await typeIn(messageElement, 'content');
const allMessages = findAll('.message');
for (const element of allMessages) {
await click(element);
}
const root = getRootElement();
await click(root);
});
示例3: visit
@test public async 'visiting /injection-factories'(assert: Assert) {
await visit('/injection-factories');
assert.equal(currentURL(), '/injection-factories', 'Test page loads');
const view = find('.mike-view');
assert.ok(view, '.mike-view found');
if (!view) { throw new Error(''); }
const viewId = view.id;
assert.ok(getViewById.call(this, viewId).get('resizeService'), 'resizeService has been injected onto views');
const component = find('.test-component');
assert.ok(component, '.test-component found');
if (!component) { throw new Error(''); }
const componentId = component.id;
// tslint:disable-next-line:max-line-length
assert.ok(getViewById.call(this, componentId).get('resizeService'), 'resizeService has been injected onto components');
}
示例4: visit
@test async 'visiting /'(assert: Assert) {
await visit('/');
assert.equal(currentURL(), '/');
const codeElement: Element | null = find('.index-view code');
if (codeElement === null) { throw new Error('no <code>'); }
assert.ok(/min\-width:\s[0-9]+px/.test('' + codeElement.textContent), 'min-width text found');
}
示例5: test
test('toggle action shows and hides dropdown', async function(assert) {
assert.expect(3);
this.set('urn', nonHdfsUrn);
await render(hbs`
{{datasets/dataset-fabric-switcher urn=urn}}
`);
assert.notOk(find(contentSelector), 'expected dropdown content class is hidden');
await triggerEvent(triggerSelector, 'mouseenter');
assert.ok(find(contentSelector), 'expected dropdown content class is shown');
await triggerEvent(triggerSelector, 'mouseleave');
assert.notOk(find(contentSelector), 'expected dropdown content class is hidden');
});
示例6:
isDisabled: () => !!find('[data-test-chat-submit][disabled]'),
示例7: test
test('an image tag is present', function(assert) {
const img = find('img');
assert.ok(img, 'the html tag is present');
assert.equal(img!.getAttribute('alt'), 'Thumbnail', 'has alt text');
});
示例8: find
toastText: () => find(toast)!.textContent,