Skip to content
This repository was archived by the owner on Jan 1, 2023. It is now read-only.

Commit b79412c

Browse files
committed
♻️ refactor array expression test
1 parent cb50d49 commit b79412c

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import pluginTester from 'babel-plugin-tester'
2+
import { buildPlugin } from '../../src/plugin'
3+
import { ArrayExpression } from '../../src/visitors/array_expression'
4+
5+
pluginTester({
6+
plugin: buildPlugin([ArrayExpression]),
7+
tests: [{
8+
title: 'Array',
9+
pluginOptions: {
10+
minJSONStringSize: 0
11+
},
12+
code: `const a = [1, "two", {three: 3}]`,
13+
output: `const a = JSON.parse('[1,"two",{"three":3}]')`
14+
}, {
15+
title: 'Array',
16+
pluginOptions: {
17+
minJSONStringSize: 0
18+
},
19+
code: `const a = [{one: 1}, {two: 2}, {three: 3}]`,
20+
output: `const a = JSON.parse('[{"one":1},{"two":2},{"three":3}]')`
21+
},]
22+
})

test/visitors/object_expression.test.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import pluginTester from 'babel-plugin-tester'
22
import { buildPlugin } from '../../src/plugin'
33
import { ObjectExpression } from '../../src/visitors/object_expression'
4-
import { ArrayExpression } from '../../src/visitors/array_expression'
54

65
pluginTester({
7-
plugin: buildPlugin([ObjectExpression, ArrayExpression]),
6+
plugin: buildPlugin([ObjectExpression]),
87
tests: [{
98
title: 'empty object',
109
pluginOptions: {
@@ -184,12 +183,5 @@ pluginTester({
184183
},
185184
code: `const a = { 1: "123", 23: 45, b: "b_val" }`,
186185
output: `const a = JSON.parse('{"1":"123","23":45,"b":"b_val"}')`
187-
}, {
188-
title: 'Array',
189-
pluginOptions: {
190-
minJSONStringSize: 0
191-
},
192-
code: `const a = [1, "two", {three: 3}]`,
193-
output: `const a = JSON.parse('[1,"two",{"three":3}]')`
194186
},]
195187
})

0 commit comments

Comments
 (0)