npx ember-test-helpers-codemod native-dom path/of/files/ or/some**/*glob.js
# or
yarn global add ember-test-helpers-codemod
ember-test-helpers-codemod native-dom path/of/files/ or/some**/*glob.js
Input (acceptance.input.js):
import { find, visit } from 'ember-native-dom-helpers';
import { currentURL, currentPath, currentRouteName } from 'ember-native-dom-helpers';
import { test } from 'qunit';
import moduleForAcceptance from '../../tests/helpers/module-for-acceptance';
moduleForAcceptance('click');
test('visiting /foo', async function(assert) {
await visit('/foo');
assert.equal(currentURL(), '/foo');
assert.ok(find('.foo'));
});
test('visiting /bar', async function(assert) {
await visit('/bar');
assert.equal(currentPath(), 'bar');
});
test('visiting /bar', async function(assert) {
await visit('/bar');
assert.equal(currentRouteName(), 'bar.index');
});
Output (acceptance.input.js):
import { find, visit, currentURL, currentRouteName } from '@ember/test-helpers';
import { currentPath } from 'ember-native-dom-helpers';
import { test } from 'qunit';
import moduleForAcceptance from '../../tests/helpers/module-for-acceptance';
moduleForAcceptance('click');
test('visiting /foo', async function(assert) {
await visit('/foo');
assert.equal(currentURL(), '/foo');
assert.ok(find('.foo'));
});
test('visiting /bar', async function(assert) {
await visit('/bar');
assert.equal(currentPath(), 'bar');
});
test('visiting /bar', async function(assert) {
await visit('/bar');
assert.equal(currentRouteName(), 'bar.index');
});
Input (double-import.input.js):
import { click, currentURL } from 'ember-native-dom-helpers';
import { find, visit } from 'ember-native-dom-helpers';
Output (double-import.input.js):
import { click, currentURL, find, visit } from '@ember/test-helpers';
Input (integration.input.js):
import {
click,
find,
findAll,
findWithAssert,
fillIn,
focus,
blur,
triggerEvent,
keyEvent,
scrollTo,
selectFiles,
waitFor,
waitUntil,
} from 'ember-native-dom-helpers';
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('foo-bar', 'Integration | Component | foo bar', {
integration: true
});
test('it renders', async function(assert) {
this.render(hbs`{{foo-bar}}`);
await click('.foo', {});
assert.equal(find('.foo').id, 'foo');
await fillIn('.foo input', 'bar');
await blur('.foo input');
assert.equal(find('.foo').textContent.trim(), 'foo');
});
test('it renders again', function(assert) {
this.render(hbs`{{foo-bar}}`);
let selector = '.foo input';
assert.equal(findAll(selector).length, 1);
assert.equal(find(selector).value, 'foo');
assert.ok(find('.foo').classList.contains('selected'));
});
test('and again', async function(assert) {
this.render(hbs`{{foo-bar}}`);
await tap('foo');
let el = findWithAssert('.foo input');
await fillIn(el, value);
await triggerEvent('.foo input', 'change');
await keyEvent('bar', 'keypress', 13, modifiers);
await focus('.foo input');
await blur('.foo input');
assert.ok(findAll('.baz')[1].classList.contains('selected'));
});
test('and yet again', async function(assert) {
this.render(hbs`{{foo-bar}}`);
await scrollTo(document, 10, 20);
await selectFiles('input[type=file]', [new Blob(['texters'], { type: 'plain/text' })]);
await waitUntil(() => find('.foo.active'));
await waitFor('.bar.selected');
assert.ok(true);
});
Output (integration.input.js):
import {
click,
find,
findAll,
fillIn,
focus,
blur,
triggerEvent,
triggerKeyEvent,
waitFor,
waitUntil,
} from '@ember/test-helpers';
import { findWithAssert, scrollTo, selectFiles } from 'ember-native-dom-helpers';
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('foo-bar', 'Integration | Component | foo bar', {
integration: true
});
test('it renders', async function(assert) {
this.render(hbs`{{foo-bar}}`);
await click('.foo', {});
assert.equal(find('.foo').id, 'foo');
await fillIn('.foo input', 'bar');
await blur('.foo input');
assert.equal(find('.foo').textContent.trim(), 'foo');
});
test('it renders again', function(assert) {
this.render(hbs`{{foo-bar}}`);
let selector = '.foo input';
assert.equal(findAll(selector).length, 1);
assert.equal(find(selector).value, 'foo');
assert.ok(find('.foo').classList.contains('selected'));
});
test('and again', async function(assert) {
this.render(hbs`{{foo-bar}}`);
await tap('foo');
let el = findWithAssert('.foo input');
await fillIn(el, value);
await triggerEvent('.foo input', 'change');
await triggerKeyEvent('bar', 'keypress', 13, modifiers);
await focus('.foo input');
await blur('.foo input');
assert.ok(findAll('.baz')[1].classList.contains('selected'));
});
test('and yet again', async function(assert) {
this.render(hbs`{{foo-bar}}`);
await scrollTo(document, 10, 20);
await selectFiles('input[type=file]', [new Blob(['texters'], { type: 'plain/text' })]);
await waitUntil(() => find('.foo.active'));
await waitFor('.bar.selected');
assert.ok(true);
});
Input (prune-import.input.js):
import { click } from 'ember-native-dom-helpers';
Output (prune-import.input.js):
import { click } from '@ember/test-helpers';