Skip to content

Commit 1b918ca

Browse files
committed
Add test coverage for hash args, @arg paths, deep props, and subexpr contexts
1 parent cd98fd3 commit 1b918ca

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

tests/lib/rules/template-no-array-prototype-extensions.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,31 @@ ruleTester.run('template-no-array-prototype-extensions', rule, {
4747
output: '<template>{{get @model "items.0.name"}}</template>',
4848
errors: [{ messageId: 'firstObject' }],
4949
},
50+
// firstObject — in hash argument context
51+
{
52+
code: '<template>{{foo bar=this.list.firstObject}}</template>',
53+
output: '<template>{{foo bar=(get this.list "0")}}</template>',
54+
errors: [{ messageId: 'firstObject' }],
55+
},
56+
// firstObject — @arg prefix path
57+
{
58+
code: '<template><Foo @bar={{@list.firstObject}} /></template>',
59+
output: '<template><Foo @bar={{get @list "0"}} /></template>',
60+
errors: [{ messageId: 'firstObject' }],
61+
},
62+
// firstObject — deeper path with trailing properties
63+
{
64+
code: '<template><Foo @bar={{this.list.firstObject.name.foo}} /></template>',
65+
output: '<template><Foo @bar={{get this.list "0.name.foo"}} /></template>',
66+
errors: [{ messageId: 'firstObject' }],
67+
},
68+
// firstObject — subexpression param context
69+
{
70+
code: '<template><div data-test={{eq this.list.firstObject.abc "def"}}>Hello</div></template>',
71+
output:
72+
'<template><div data-test={{eq (get this.list "0.abc") "def"}}>Hello</div></template>',
73+
errors: [{ messageId: 'firstObject' }],
74+
},
5075
// lastObject — no fix available
5176
{
5277
code: '<template>{{this.users.lastObject}}</template>',

0 commit comments

Comments
 (0)