Skip to content
This repository was archived by the owner on May 26, 2019. It is now read-only.

Fix second test in autocomplete-component #2271

Merged
merged 1 commit into from
Mar 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions source/tutorial/autocomplete-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,10 @@ represented by the variable `FILTERED_ITEMS` when any value is set.

We force the action by generating a `keyUp` event on our input field, and then assert that only one item is rendered.

First add `triggerKeyEvent` to the list of imports. The [`triggerKeyEvent`](https://github.com/emberjs/ember-test-helpers/blob/master/API.md#triggerkeyevent) helper sends a key stroke event to the UI, simulating the user typing a key.
First add `triggerKeyEvent` and `fillIn` to the list of imports. The [`fillIn`](https://github.com/emberjs/ember-test-helpers/blob/master/API.md#fillin) helper simulates the user filling in the element. The [`triggerKeyEvent`](https://github.com/emberjs/ember-test-helpers/blob/master/API.md#triggerkeyevent) helper sends a key stroke event to the UI, simulating the user typing a key.

```tests/integration/components/list-filter-test.js
import { render, settled, triggerKeyEvent } from '@ember/test-helpers';
import { render, settled, triggerKeyEvent, fillIn } from '@ember/test-helpers';
```

Now use it to simulate the user typing a key into the search field.
Expand Down Expand Up @@ -501,6 +501,8 @@ test('should update with matching listings', async function (assert) {
{{/list-filter}}
`);

// filling in the component's input field with 's'
await fillIn(this.element.querySelector('.list-filter input'),'s');
// The keyup event here should invoke an action that will cause the list to be filtered
await triggerKeyEvent(this.element.querySelector('.list-filter input'), "keyup", 83);

Expand Down