Skip to content

Commit

Permalink
Correcting test-support helper extraction (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
ygongdev authored Nov 19, 2019
1 parent bc34f8c commit 80e9a8f
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 10 deletions.
4 changes: 1 addition & 3 deletions MIGRATION_GUIDE_V2.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,4 @@
### Testing
1. The `drag` and `reorder` test helpers are no longer global `async` helpers. They are now importable.

```javascript
import { drag, reorder } from 'ember-sortable/test-helpers'
```
Refer to [Testing Section](/README.md#Testing) for more details.
33 changes: 30 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,41 @@ and returns a `string` constructed from the `config`.

* [`drag`][drag]: Drags elements by an offset specified in pixels.
* [`reorder`][reorder]: Reorders elements to the specified state.
* [`keyboard`][keyboard]: Keycode constants for quick.

[drag]: addon/helpers/drag.js
[reorder]: addon/helpers/reorder.js
[drag]: addon-test-support/helpers/drag.js
[reorder]: addon-test-support/helpers/reorder.js
[keyboard]: addon-test-support/utils/kebyoard.js

To include them in your application, you can import them:

```js
import { drag, reorder } from 'ember-sortable/test-helpers';
import { drag, reorder } from 'ember-sortable/test-support/helpers';
import { ENTER_KEY_CODE, SPACE_KEY_CODE, ESCAPE_KEY_CODE, ARROW_KEY_CODES } from "ember-sortable/test-support/utils/keyboard";
```

### Examples
`Reorder`
```js
await reorder(
'mouse',
'[data-test-vertical-demo-handle]',
...order
);
```

`Drag`
```js
await drag('mouse', '[data-test-scrollable-demo-handle] .handle', () => { return {dy: itemHeight() * 2 + 1, dx: undefined}});
```

`Keyboard`
```js
await triggerKeyEvent(
'[data-test-vertical-demo-handle]',
'keydown',
ENTER_KEY_CODE
);
```

## Developing
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions addon-test-support/helpers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { drag } from './drag';
import { reorder } from './reorder';

export {
drag,
reorder,
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { find, findAll } from '@ember/test-helpers';
import { drag } from '../helpers/drag';
import { drag } from './drag';
import { getOffset } from '../utils/offset';
/**
In tests, the dummy app is rendered at half size.
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions tests/acceptance/smoke-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { module, test } from 'qunit';
import { visit, find, findAll, triggerKeyEvent, focus, blur } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import { drag } from '../ember-sortable/helpers/drag';
import { reorder } from '../ember-sortable/helpers/reorder';
import { ENTER_KEY_CODE, SPACE_KEY_CODE, ESCAPE_KEY_CODE, ARROW_KEY_CODES } from "../ember-sortable/utils/keyboard";
import { drag, reorder } from 'ember-sortable/test-support/helpers';
import { ENTER_KEY_CODE, SPACE_KEY_CODE, ESCAPE_KEY_CODE, ARROW_KEY_CODES } from "ember-sortable/test-support/utils/keyboard";
import a11yAudit from 'ember-a11y-testing/test-support/audit';

module('Acceptance | smoke', function(hooks) {
Expand Down

0 comments on commit 80e9a8f

Please sign in to comment.