@@ -6,7 +6,7 @@ import { GET_URL_CODE } from '../src/constants';
6
6
describe ( 'loader' , ( ) => {
7
7
it ( 'should convert to requires' , ( ) => {
8
8
const result = loader . call (
9
- { } ,
9
+ { mode : 'development' } ,
10
10
'Text <img src="image.png"><img src="~bootstrap-img"> Text <img src="">'
11
11
) ;
12
12
@@ -18,6 +18,7 @@ describe('loader', () => {
18
18
it ( 'should accept attrs from query' , ( ) => {
19
19
const result = loader . call (
20
20
{
21
+ mode : 'development' ,
21
22
query : '?attrs=script:src' ,
22
23
} ,
23
24
'Text <script src="script.js"><img src="image.png">'
@@ -30,6 +31,7 @@ describe('loader', () => {
30
31
it ( 'should accept attrs from query (space separated)' , ( ) => {
31
32
const result = loader . call (
32
33
{
34
+ mode : 'development' ,
33
35
query : '?attrs=script:src img:src' ,
34
36
} ,
35
37
'Text <script src="script.js"><img src="image.png">'
@@ -42,6 +44,7 @@ describe('loader', () => {
42
44
it ( 'should accept attrs from query (multiple)' , ( ) => {
43
45
const result = loader . call (
44
46
{
47
+ mode : 'development' ,
45
48
query : '?attrs[]=script:src&attrs[]=img:src' ,
46
49
} ,
47
50
'Text <script src="script.js"><img src="image.png">'
@@ -54,6 +57,7 @@ describe('loader', () => {
54
57
it ( 'should accept :attribute (empty tag) from query' , ( ) => {
55
58
const result = loader . call (
56
59
{
60
+ mode : 'development' ,
57
61
query : '?attrs[]=:custom-src' ,
58
62
} ,
59
63
'Text <custom-element custom-src="image1.png"><custom-img custom-src="image2.png"/></custom-element>'
@@ -66,6 +70,7 @@ describe('loader', () => {
66
70
it ( 'should accept :attribute (empty tag) from query and not collide with similar attributes' , ( ) => {
67
71
const result = loader . call (
68
72
{
73
+ mode : 'development' ,
69
74
query : '?attrs[]=:custom-src' ,
70
75
} ,
71
76
'Text <custom-element custom-src="image1.png" custom-src-other="other.png"><custom-img custom-src="image2.png"/></custom-element>'
@@ -77,7 +82,7 @@ describe('loader', () => {
77
82
} ) ;
78
83
it ( 'should not make bad things with templates' , ( ) => {
79
84
const result = loader . call (
80
- { } ,
85
+ { mode : 'development' } ,
81
86
'<h3>#{number} {customer}</h3>\n<p> {title} </p>'
82
87
) ;
83
88
@@ -88,7 +93,7 @@ describe('loader', () => {
88
93
89
94
it ( 'should preserve escaped quotes' , ( ) => {
90
95
const result = loader . call (
91
- { } ,
96
+ { mode : 'development' } ,
92
97
'<script>{"json": "with \\"quotes\\" in value"}</script>'
93
98
) ;
94
99
@@ -98,7 +103,10 @@ describe('loader', () => {
98
103
} ) ;
99
104
100
105
it ( 'should not translate root-relative urls (without root query)' , ( ) => {
101
- const result = loader . call ( { } , 'Text <img src="/image.png">' ) ;
106
+ const result = loader . call (
107
+ { mode : 'development' } ,
108
+ 'Text <img src="/image.png">'
109
+ ) ;
102
110
103
111
expect ( result ) . toBe (
104
112
`${ GET_URL_CODE } module.exports = "Text <img src=\\"/image.png\\">";`
@@ -107,6 +115,7 @@ describe('loader', () => {
107
115
it ( 'should accept root from query' , ( ) => {
108
116
const result = loader . call (
109
117
{
118
+ mode : 'development' ,
110
119
query : '?root=/test' ,
111
120
} ,
112
121
'Text <img src="/image.png">'
@@ -117,32 +126,41 @@ describe('loader', () => {
117
126
) ;
118
127
} ) ;
119
128
it ( 'should ignore hash fragments in URLs' , ( ) => {
120
- const result = loader . call ( { } , '<img src="icons.svg#hash">' ) ;
129
+ const result = loader . call (
130
+ { mode : 'development' } ,
131
+ '<img src="icons.svg#hash">'
132
+ ) ;
121
133
122
134
expect ( result ) . toBe (
123
135
`${ GET_URL_CODE } module.exports = "<img src=\\"" + __url__(require("./icons.svg")) + "#hash\\">";`
124
136
) ;
125
137
} ) ;
126
138
it ( "should ignore anchor with 'mailto:' in the href attribute" , ( ) => {
127
139
const result = loader . call (
128
- { } ,
140
+ { mode : 'development' } ,
129
141
'<a href="mailto:username@exampledomain.com"></a>'
130
142
) ;
131
143
132
144
expect ( result ) . toBe (
133
145
`${ GET_URL_CODE } module.exports = "<a href=\\"mailto:username@exampledomain.com\\"></a>";`
134
146
) ;
135
147
} ) ;
148
+
136
149
it ( 'should ignore interpolations by default' , ( ) => {
137
- const result = loader . call ( { } , '<img src="${"Hello " + (1+1)}">' ) ;
150
+ const result = loader . call (
151
+ { mode : 'development' } ,
152
+ '<img src="${"Hello " + (1+1)}">'
153
+ ) ;
138
154
139
155
expect ( result ) . toBe (
140
156
`${ GET_URL_CODE } module.exports = "<img src=\\"\${\\"Hello \\" + (1+1)}\\">";`
141
157
) ;
142
158
} ) ;
159
+
143
160
it ( 'should enable interpolations when using interpolate flag' , ( ) => {
144
161
const result = loader . call (
145
162
{
163
+ mode : 'development' ,
146
164
query : '?interpolate' ,
147
165
} ,
148
166
'<img src="${"Hello " + (1+1)}">'
@@ -155,6 +173,7 @@ describe('loader', () => {
155
173
it ( 'should not change handling of quotes when interpolation is enabled' , ( ) => {
156
174
const result = loader . call (
157
175
{
176
+ mode : 'development' ,
158
177
query : '?interpolate' ,
159
178
} ,
160
179
'<script>{"json": "with \\"quotes\\" in value"}</script>'
@@ -167,6 +186,7 @@ describe('loader', () => {
167
186
it ( 'should enable interpolations when using interpolate=require flag and only require function be translate' , ( ) => {
168
187
const result = loader . call (
169
188
{
189
+ mode : 'development' ,
170
190
query : '?interpolate=require' ,
171
191
} ,
172
192
'<a href="${list.href}"><img src="${require("./test.jpg")}" /></a>'
0 commit comments