@@ -3,9 +3,9 @@ jest.autoMockOff();
3
3
const babel = require ( "babel-core" ) ;
4
4
const unpad = require ( "../../../utils/unpad" ) ;
5
5
6
- function transform ( code ) {
6
+ function transform ( code , opts = { } ) {
7
7
return babel . transform ( code , {
8
- plugins : [ require ( "../src/index" ) ]
8
+ plugins : [ [ require ( "../src/index" ) , opts ] ]
9
9
} ) . code ;
10
10
}
11
11
@@ -83,7 +83,7 @@ describe("constant-folding-plugin", () => {
83
83
"<\\\\/script";
84
84
`
85
85
) ;
86
- expect ( transform ( source ) ) . toBe ( expected ) ;
86
+ expect ( transform ( source , { isScriptContext : true } ) ) . toBe ( expected ) ;
87
87
} ) ;
88
88
89
89
it ( "should handle style escape" , ( ) => {
@@ -98,7 +98,7 @@ describe("constant-folding-plugin", () => {
98
98
"<\\\\/style";
99
99
`
100
100
) ;
101
- expect ( transform ( source ) ) . toBe ( expected ) ;
101
+ expect ( transform ( source , { isScriptContext : true } ) ) . toBe ( expected ) ;
102
102
} ) ;
103
103
104
104
it ( "should handle html comment escape" , ( ) => {
@@ -113,6 +113,20 @@ describe("constant-folding-plugin", () => {
113
113
"\\\\x3C!--";
114
114
`
115
115
) ;
116
+ expect ( transform ( source , { isScriptContext : true } ) ) . toBe ( expected ) ;
117
+ } ) ;
118
+
119
+ it ( "should fix #440" , ( ) => {
120
+ const source = unpad (
121
+ `
122
+ var x = "'cool'" + "test";
123
+ `
124
+ ) ;
125
+ const expected = unpad (
126
+ `
127
+ var x = "'cool'test";
128
+ `
129
+ ) ;
116
130
expect ( transform ( source ) ) . toBe ( expected ) ;
117
131
} ) ;
118
132
} ) ;
0 commit comments