-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19472 from Windvis/bugfix/transform-attrs-into-ar…
…gs-block-params
- Loading branch information
Showing
2 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
packages/ember-template-compiler/tests/plugins/transform-attrs-into-args-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import TransformTestCase from '../utils/transform-test-case'; | ||
import { moduleFor, RenderingTestCase } from 'internal-test-helpers'; | ||
|
||
moduleFor( | ||
'ember-template-compiler: transforming attrs into @args', | ||
class extends TransformTestCase { | ||
['@test it transforms attrs into @args']() { | ||
expectDeprecation(() => { | ||
this.assertTransformed(`{{attrs.foo}}`, `{{@foo}}`); | ||
}, /Using {{attrs}} to reference named arguments has been deprecated. {{attrs.foo}} should be updated to {{@foo}}./); | ||
|
||
expectDeprecation(() => { | ||
this.assertTransformed(`{{attrs.foo.bar}}`, `{{@foo.bar}}`); | ||
}, /Using {{attrs}} to reference named arguments has been deprecated. {{attrs.foo.bar}} should be updated to {{@foo.bar}}./); | ||
|
||
expectDeprecation(() => { | ||
this.assertTransformed(`{{if attrs.foo "foo"}}`, `{{if @foo "foo"}}`); | ||
}, /Using {{attrs}} to reference named arguments has been deprecated. {{attrs.foo}} should be updated to {{@foo}}./); | ||
|
||
expectDeprecation(() => { | ||
this.assertTransformed(`{{#if attrs.foo}}{{/if}}`, `{{#if @foo}}{{/if}}`); | ||
}, /Using {{attrs}} to reference named arguments has been deprecated. {{attrs.foo}} should be updated to {{@foo}}./); | ||
|
||
expectDeprecation(() => { | ||
this.assertTransformed(`{{deeply (nested attrs.foo.bar)}}`, `{{deeply (nested @foo.bar)}}`); | ||
}, /Using {{attrs}} to reference named arguments has been deprecated. {{attrs.foo.bar}} should be updated to {{@foo.bar}}./); | ||
|
||
expectDeprecation(() => { | ||
this.assertTransformed(`{{this.attrs.foo}}`, `{{@foo}}`); | ||
}, /Using {{attrs}} to reference named arguments has been deprecated. {{attrs.foo}} should be updated to {{@foo}}./); | ||
} | ||
} | ||
); | ||
|
||
moduleFor( | ||
'ember-template-compiler: not transforming block params named "attrs" into @args', | ||
class extends RenderingTestCase { | ||
["@test it doesn't transform block params"]() { | ||
this.registerComponent('foo', { | ||
template: '{{#let "foo" as |attrs|}}{{attrs}}{{/let}}', | ||
}); | ||
this.render('<Foo />'); | ||
this.assertComponentElement(this.firstChild, { content: 'foo' }); | ||
} | ||
|
||
["@test it doesn't transform component block params"]() { | ||
this.registerComponent('foo', { | ||
template: '{{yield "foo"}}', | ||
}); | ||
this.render('<Foo as |attrs|>{{attrs}}</Foo>'); | ||
this.assertComponentElement(this.firstChild, { content: 'foo' }); | ||
} | ||
|
||
["@test it doesn't transform block params with nested keys"]() { | ||
this.registerComponent('foo', { | ||
template: '{{yield (hash bar="baz")}}', | ||
}); | ||
this.render('<Foo as |attrs|>{{attrs.bar}}</Foo>'); | ||
this.assertComponentElement(this.firstChild, { content: 'baz' }); | ||
} | ||
} | ||
); |