|
| 1 | +# this-render-migration |
| 2 | +This codemod transform is to replace deprecated this.render() with render() from '@ember/test-helpers' package |
| 3 | + |
| 4 | +## Usage |
| 5 | + |
| 6 | +``` |
| 7 | +npx ember-test-helpers-codemod this-render-migration path/of/files/ or/some**/*glob.js |
| 8 | +
|
| 9 | +# or |
| 10 | +
|
| 11 | +yarn global add ember-test-helpers-codemod |
| 12 | +ember-test-helpers-codemod this-render-migration path/of/files/ or/some**/*glob.js |
| 13 | +``` |
| 14 | + |
| 15 | +## Input / Output |
| 16 | + |
| 17 | +<!--FIXTURES_TOC_START--> |
| 18 | +* [basic](#basic) |
| 19 | +* [has-no-ember-test-helpers-import](#has-no-ember-test-helpers-import) |
| 20 | +<!--FIXTURES_TOC_END--> |
| 21 | + |
| 22 | +<!--FIXTURES_CONTENT_START--> |
| 23 | +--- |
| 24 | +<a id="basic">**basic**</a> |
| 25 | + |
| 26 | +**Input** (<small>[basic.input.js](transforms/this-render-migration/__testfixtures__/basic.input.js)</small>): |
| 27 | +```js |
| 28 | +import { click } from '@ember/test-helpers'; |
| 29 | + |
| 30 | +test('It handles switching selected option on click and fires onSelect event', async function(assert) { |
| 31 | + this.onSelectMock = this.sandbox.stub(); |
| 32 | + await this.render(hbs` |
| 33 | + <Common::TimeCommitmentSelector @timeCommitmentOptions={{timeCommitmentOptionsMock}} @onSelect={{onSelectMock}}> |
| 34 | + </Common::TimeCommitmentSelector> |
| 35 | + `); |
| 36 | +}) |
| 37 | + |
| 38 | +``` |
| 39 | + |
| 40 | +**Output** (<small>[basic.input.js](transforms/this-render-migration/__testfixtures__/basic.output.js)</small>): |
| 41 | +```js |
| 42 | +import { click, render } from '@ember/test-helpers'; |
| 43 | + |
| 44 | +test('It handles switching selected option on click and fires onSelect event', async function(assert) { |
| 45 | + this.onSelectMock = this.sandbox.stub(); |
| 46 | + await render(hbs` |
| 47 | + <Common::TimeCommitmentSelector @timeCommitmentOptions={{timeCommitmentOptionsMock}} @onSelect={{onSelectMock}}> |
| 48 | + </Common::TimeCommitmentSelector> |
| 49 | + `); |
| 50 | +}) |
| 51 | +``` |
| 52 | +--- |
| 53 | +<a id="has-no-ember-test-helpers-import">**has-no-ember-test-helpers-import**</a> |
| 54 | + |
| 55 | +**Input** (<small>[has-no-ember-test-helpers-import.input.js](transforms/this-render-migration/__testfixtures__/has-no-ember-test-helpers-import.input.js)</small>): |
| 56 | +```js |
| 57 | +test('It handles switching selected option on click and fires onSelect event', async function(assert) { |
| 58 | + this.onSelectMock = this.sandbox.stub(); |
| 59 | + await this.render(hbs` |
| 60 | + <Common::TimeCommitmentSelector @timeCommitmentOptions={{timeCommitmentOptionsMock}} @onSelect={{onSelectMock}}> |
| 61 | + </Common::TimeCommitmentSelector> |
| 62 | + `); |
| 63 | +}) |
| 64 | + |
| 65 | +``` |
| 66 | + |
| 67 | +**Output** (<small>[has-no-ember-test-helpers-import.input.js](transforms/this-render-migration/__testfixtures__/has-no-ember-test-helpers-import.output.js)</small>): |
| 68 | +```js |
| 69 | +import { render } from '@ember/test-helpers'; |
| 70 | +test('It handles switching selected option on click and fires onSelect event', async function(assert) { |
| 71 | + this.onSelectMock = this.sandbox.stub(); |
| 72 | + await render(hbs` |
| 73 | + <Common::TimeCommitmentSelector @timeCommitmentOptions={{timeCommitmentOptionsMock}} @onSelect={{onSelectMock}}> |
| 74 | + </Common::TimeCommitmentSelector> |
| 75 | + `); |
| 76 | +}) |
| 77 | + |
| 78 | +``` |
| 79 | +<!--FIXTURE_CONTENT_END--> |
0 commit comments