Skip to content

Commit

Permalink
chore: add unit test for json array
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Nov 1, 2024
1 parent a7713af commit 41ebe72
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/vite/src/node/__tests__/plugins/json.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ describe('transform', () => {
return (plugin.transform! as Function)(input, 'test.json').code
}

test("namedExports: true, stringify: 'auto' should not transformed an array input", () => {
const actualSmall = transform(
'[{"a":1,"b":2}]',
{ namedExports: true, stringify: 'auto' },
false,
)
expect(actualSmall).toMatchInlineSnapshot(`
"export default [
{
a: 1,
b: 2
}
];"
`)
})

test('namedExports: true, stringify: false', () => {
const actual = transform(
'{"a":1,\n"🫠": "",\n"const": false}',
Expand Down

0 comments on commit 41ebe72

Please sign in to comment.