gpt4 book ai didi

jquery - 如何在 ember 集成测试中聚焦/模糊某个组件?

转载 作者:行者123 更新时间:2023-12-03 22:42:01 25 4
gpt4 key购买 nike

在测试 Ember.js 组件时如何触发焦点和模糊事件?

this.$().focus();this.$('input').focus(); 似乎有效,但在 phantomjs 和 chrome 中表现不同.

另外 this.$().blur();this.$().focusout(); 似乎在 phantomjs 和 chrome 上都不起作用。

最佳答案

较新版本的 Ember 有测试助手,可用于聚焦或模糊。

... 
import { find, focus, blur, render } from '@ember/test-helpers';


module('Integration | Component | example-input', function(hooks) {

test('it can be focused', async function(assert) {
await render(hbs`<myInput />`);
const input = find('input')

await focus(input)
await blur(input)
});

});

模糊:https://github.com/emberjs/ember-test-helpers/blob/master/API.md#blur

焦点:https://github.com/emberjs/ember-test-helpers/blob/master/API.md#focus

关于jquery - 如何在 ember 集成测试中聚焦/模糊某个组件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37036337/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com