@@ -24,6 +24,7 @@ describe('i18n', () => {
24
24
} ,
25
25
i18n : {
26
26
en : {
27
+ name : 'localized name' ,
27
28
description : 'i18n description' ,
28
29
} ,
29
30
} ,
@@ -41,6 +42,7 @@ describe('i18n', () => {
41
42
input . writeFileSync (
42
43
'/headers.json' ,
43
44
JSON . stringify ( {
45
+ name : 'localized name' ,
44
46
description : 'i18n description' ,
45
47
} ) ,
46
48
) ;
@@ -76,6 +78,7 @@ describe('i18n', () => {
76
78
i18n : {
77
79
en : ( headers ) : HeadersProps => ( {
78
80
...headers ,
81
+ name : 'localized name' ,
79
82
description : 'i18n description' ,
80
83
} ) ,
81
84
} ,
@@ -89,23 +92,80 @@ describe('i18n', () => {
89
92
} ) ;
90
93
} ) ;
91
94
92
- it ( 'unlocalizable tags' , ( ) => {
93
- const promise = compile ( input , {
94
- ...Fixtures . webpackConfig ,
95
- plugins : [
96
- new UserscriptPlugin ( {
97
- headers : {
98
- name : 'i18n' ,
99
- } ,
100
- i18n : {
101
- en : {
102
- downloadURL : 'https://example.com' ,
95
+ describe ( 'unlocalizable tags' , ( ) => {
96
+ it ( 'are rejected in strict mode' , ( ) => {
97
+ const promise = compile ( input , {
98
+ ...Fixtures . webpackConfig ,
99
+ plugins : [
100
+ new UserscriptPlugin ( {
101
+ headers : {
102
+ name : 'i18n' ,
103
103
} ,
104
- } ,
105
- } ) ,
106
- ] ,
104
+ i18n : {
105
+ en : {
106
+ name : 'localized name' ,
107
+ downloadURL : 'https://example.com' ,
108
+ } ,
109
+ } ,
110
+ } ) ,
111
+ ] ,
112
+ } ) ;
113
+
114
+ return expect ( promise ) . toReject ( ) ;
107
115
} ) ;
108
116
109
- return expect ( promise ) . toReject ( ) ;
117
+ it ( 'are allowed in non-strict mode' , async ( ) => {
118
+ const output = await compile ( input , {
119
+ ...Fixtures . webpackConfig ,
120
+ plugins : [
121
+ new UserscriptPlugin ( {
122
+ headers : {
123
+ name : 'non-strict i18n' ,
124
+ } ,
125
+ i18n : {
126
+ en : ( headers ) : HeadersProps => ( {
127
+ ...headers ,
128
+ downloadURL : 'https://example.com' ,
129
+ } ) ,
130
+ } ,
131
+ strict : false ,
132
+ } ) ,
133
+ ] ,
134
+ } ) ;
135
+
136
+ expect ( output . toJSON ( ) ) . toEqual ( {
137
+ '/dist/output.user.js' : Fixtures . entryUserJs (
138
+ Fixtures . nonStrictI18nHeaders ,
139
+ ) ,
140
+ '/dist/output.meta.js' : Fixtures . nonStrictI18nHeaders ,
141
+ } ) ;
142
+ } ) ;
143
+
144
+ it ( 'are stripped in whitelist mode' , async ( ) => {
145
+ const output = await compile ( input , {
146
+ ...Fixtures . webpackConfig ,
147
+ plugins : [
148
+ new UserscriptPlugin ( {
149
+ headers : {
150
+ name : 'i18n' ,
151
+ } ,
152
+ i18n : {
153
+ en : {
154
+ name : 'localized name' ,
155
+ description : 'i18n description' ,
156
+ // downloadURL will be stripped
157
+ downloadURL : 'https://example.com' ,
158
+ } ,
159
+ } ,
160
+ whitelist : true ,
161
+ } ) ,
162
+ ] ,
163
+ } ) ;
164
+
165
+ expect ( output . toJSON ( ) ) . toEqual ( {
166
+ '/dist/output.user.js' : Fixtures . entryUserJs ( Fixtures . i18nHeaders ) ,
167
+ '/dist/output.meta.js' : Fixtures . i18nHeaders ,
168
+ } ) ;
169
+ } ) ;
110
170
} ) ;
111
171
} ) ;
0 commit comments