Skip to content

Latest commit

 

History

History
79 lines (63 loc) · 2.77 KB

File metadata and controls

79 lines (63 loc) · 2.77 KB

this-render-migration

This codemod transform is to replace deprecated this.render() with render() from '@ember/test-helpers' package

Usage

npx ember-test-helpers-codemod this-render-migration path/of/files/ or/some**/*glob.js

# or

yarn global add ember-test-helpers-codemod
ember-test-helpers-codemod this-render-migration path/of/files/ or/some**/*glob.js

Input / Output


basic

Input (basic.input.js):

import { click } from '@ember/test-helpers';

test('It handles switching selected option on click and fires onSelect event', async function(assert) {
    this.onSelectMock = this.sandbox.stub();
    await this.render(hbs`
      <Common::TimeCommitmentSelector @timeCommitmentOptions={{timeCommitmentOptionsMock}} @onSelect={{onSelectMock}}>
      </Common::TimeCommitmentSelector>
    `);
})

Output (basic.input.js):

import { click, render } from '@ember/test-helpers';

test('It handles switching selected option on click and fires onSelect event', async function(assert) {
    this.onSelectMock = this.sandbox.stub();
    await render(hbs`
      <Common::TimeCommitmentSelector @timeCommitmentOptions={{timeCommitmentOptionsMock}} @onSelect={{onSelectMock}}>
      </Common::TimeCommitmentSelector>
    `);
})

has-no-ember-test-helpers-import

Input (has-no-ember-test-helpers-import.input.js):

test('It handles switching selected option on click and fires onSelect event', async function(assert) {
    this.onSelectMock = this.sandbox.stub();
    await this.render(hbs`
      <Common::TimeCommitmentSelector @timeCommitmentOptions={{timeCommitmentOptionsMock}} @onSelect={{onSelectMock}}>
      </Common::TimeCommitmentSelector>
    `);
})

Output (has-no-ember-test-helpers-import.input.js):

import { render } from '@ember/test-helpers';
test('It handles switching selected option on click and fires onSelect event', async function(assert) {
    this.onSelectMock = this.sandbox.stub();
    await render(hbs`
      <Common::TimeCommitmentSelector @timeCommitmentOptions={{timeCommitmentOptionsMock}} @onSelect={{onSelectMock}}>
      </Common::TimeCommitmentSelector>
    `);
})