From bbb6b82df06d1167434075dd06fc5cf3c56ef467 Mon Sep 17 00:00:00 2001 From: Scott Newcomer Date: Sat, 20 Nov 2021 11:07:01 -0600 Subject: [PATCH] refactor focus input test --- tests/unit/setup-rendering-context-test.js | 49 ++++++++++------------ 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/tests/unit/setup-rendering-context-test.js b/tests/unit/setup-rendering-context-test.js index 4e24e1df1..d6701e22c 100644 --- a/tests/unit/setup-rendering-context-test.js +++ b/tests/unit/setup-rendering-context-test.js @@ -440,34 +440,27 @@ module('setupRenderingContext', function (hooks) { assert.equal(this.get('value'), '1'); }); - // test('it supports dom triggered focus events', async function (assert) { - // this.owner.register( - // 'component:my-input', - // TextField.extend({ - // init() { - // this._super(...arguments); - - // this.set('value', 'init'); - // }, - // focusIn() { - // this.set('value', 'focusin'); - // }, - // focusOut() { - // this.set('value', 'focusout'); - // }, - // }) - // ); - // await this.render(hbs`{{my-input}}`); - - // let input = this.element.querySelector('input'); - // assert.equal(input.value, 'init'); - - // await focus(input); - // assert.equal(input.value, 'focusin'); - - // await blur(input); - // assert.equal(input.value, 'focusout'); - // }); + test('it supports dom triggered focus events', async function (assert) { + this.owner.register( + 'template:components/x-input', + hbs`` + ); + await render(hbs``); + + let input = this.element.querySelector('input'); + input.addEventListener ('blur', () => { + assert.step('blur'); + }); + + input.addEventListener('focus', () => { + assert.step('focus'); + }); + + await focus(input); + await blur(input); + + assert.verifySteps(['focus', 'blur']); + }); test('two way bound arguments are updated', async function (assert) { this.owner.register(