Skip to content

Commit 85c822e

Browse files
committed
Test trailingComma
1 parent 73ea7be commit 85c822e

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

tests/helpers.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ export function massageAst(ast: any, parser: 'babel' | 'angular'): any {
3939
delete ast.extra.parenStart;
4040
}
4141

42+
if (
43+
(ast.type === 'ArrayExpression' || ast.type === 'ObjectExpression') &&
44+
typeof ast.extra?.trailingComma === 'number'
45+
) {
46+
delete ast.extra.trailingComma;
47+
}
48+
4249
delete ast.loc;
4350
}
4451

tests/transform.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ const testCases: TestCase[] = [
208208
{
209209
expectedAngularType: 'LiteralArray',
210210
expectedEstreeType: 'ArrayExpression',
211-
text: ' [ 1 ] ',
211+
text: ' ( ( [ ( ( 1 ) ), ] ) ) ',
212212
},
213213
{
214214
expectedAngularType: 'LiteralMap',
215215
expectedEstreeType: 'ObjectExpression',
216-
text: ' ( ( { "a" : ( ( 1 ) ) } ) )',
216+
text: ' ( ( { "a" : ( ( 1 ) ), } ) )',
217217
},
218218
{
219219
expectedAngularType: 'LiteralMap',

0 commit comments

Comments
 (0)