Skip to content

Commit a780f76

Browse files
committed
Improvements in code snippets for autocomplete-component tutorial
**WHY**: the existing code diff highlights were confusing when going through the tutorial. **WHAT**: - update diff to highlight *all* added lines in each section - add diff highlighting and more lines to snippet where `triggerKeyEvent` and `fillIn` are added so provide more context on where in the file this happens. - update snippet where 2nd integration test for component was added to make it clearer that it is all new content. Also update phrasing of the code comments in the snippet to prevent usage of a hyphen that was causing weird syntax highlighting.
1 parent 3a00d35 commit a780f76

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

guides/v3.1.0/tutorial/autocomplete-component.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ Since our component is expecting the filter process to be asynchronous, we retur
371371
372372
Next, we'll add the call to render the component to show the cities we've provided above.
373373
374-
```javascript {data-filename="tests/integration/components/list-filter-test.js" data-diff="+20,+21,+22,+23,+24,+25,+26,+27,+28,+29,+30,+31,+32,+33"}
374+
```javascript {data-filename="tests/integration/components/list-filter-test.js" data-diff="+18,+19,+20,+21,+22,+23,+24,+25,+26,+27,+28,+29,+30,+31"}
375375
import { module, test } from 'qunit';
376376
import { setupRenderingTest } from 'ember-qunit';
377377
import { render } from '@ember/test-helpers';
@@ -468,13 +468,17 @@ We force the action by generating a `keyUp` event on our input field, and then a
468468
469469
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.
470470
471-
```javascript {data-filename=tests/integration/components/list-filter-test.js}
471+
```javascript {data-filename="tests/integration/components/list-filter-test.js" data-diff="+3"}
472+
import { module, test } from 'qunit';
473+
import { setupRenderingTest } from 'ember-qunit';
472474
import { render, settled, triggerKeyEvent, fillIn } from '@ember/test-helpers';
475+
import hbs from 'htmlbars-inline-precompile';
476+
import { resolve } from 'rsvp';
473477
```
474478
475479
Now use it to simulate the user typing a key into the search field.
476480
477-
```javascript {data-filename="tests/integration/components/list-filter-test.js" data-diff="+27"}
481+
```javascript {data-filename="tests/integration/components/list-filter-test.js" data-diff="+1,+2,+3,+4,+5,+6,+7,+8,+9,+10,+11,+12,+13,+14,+15,+16,+17,+18,+19,+20,+21,+22,+23,+24,+25,+26,+27,+28,+29,+30,+31,+32,+33,+34,+35"}
478482
test('should update with matching listings', async function (assert) {
479483
this.set('filterByCity', (val) => {
480484
if (val === '') {
@@ -500,9 +504,9 @@ test('should update with matching listings', async function (assert) {
500504
{{/list-filter}}
501505
`);
502506

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

508512
return settled().then(() => {

0 commit comments

Comments
 (0)