@@ -133,74 +133,82 @@ describe(`pluginOptionsSchema`, () => {
133
133
`"workboxConfig.clientsClaim" must be a boolean` ,
134
134
]
135
135
136
- const { errors } = await testPluginOptionsSchema ( pluginOptionsSchema , {
137
- precachePages : [ 1 , 2 , 3 ] ,
138
- appendScript : 1223 ,
139
- debug : `This should be a boolean` ,
140
- workboxConfig : {
141
- importWorkboxFrom : 123 ,
142
- globDirectory : 456 ,
143
- globPatterns : [ 1 , 2 , 3 ] ,
144
- modifyURLPrefix : {
145
- "/" : 123 ,
146
- } ,
147
- cacheId : 123 ,
148
- dontCacheBustURLsMatching : `This should be a regexp` ,
149
- runtimeCaching : [
150
- {
151
- urlPattern : / ( \. j s $ | \. c s s $ | s t a t i c \/ ) / ,
152
- handler : `Something Invalid` ,
136
+ const { isValid, errors } = await testPluginOptionsSchema (
137
+ pluginOptionsSchema ,
138
+ {
139
+ precachePages : [ 1 , 2 , 3 ] ,
140
+ appendScript : 1223 ,
141
+ debug : `This should be a boolean` ,
142
+ workboxConfig : {
143
+ importWorkboxFrom : 123 ,
144
+ globDirectory : 456 ,
145
+ globPatterns : [ 1 , 2 , 3 ] ,
146
+ modifyURLPrefix : {
147
+ "/" : 123 ,
153
148
} ,
154
- 2 ,
155
- 3 ,
156
- ] ,
157
- skipWaiting : `This should be a boolean` ,
158
- clientsClaim : `This should be a boolean` ,
159
- } ,
160
- } )
149
+ cacheId : 123 ,
150
+ dontCacheBustURLsMatching : `This should be a regexp` ,
151
+ runtimeCaching : [
152
+ {
153
+ urlPattern : / ( \. j s $ | \. c s s $ | s t a t i c \/ ) / ,
154
+ handler : `Something Invalid` ,
155
+ } ,
156
+ 2 ,
157
+ 3 ,
158
+ ] ,
159
+ skipWaiting : `This should be a boolean` ,
160
+ clientsClaim : `This should be a boolean` ,
161
+ } ,
162
+ }
163
+ )
161
164
165
+ expect ( isValid ) . toBe ( false )
162
166
expect ( errors ) . toEqual ( expectedErrors )
163
167
} )
164
168
165
169
it ( `should validate the schema` , async ( ) => {
166
- const { isValid } = await testPluginOptionsSchema ( pluginOptionsSchema , {
167
- precachePages : [ `/about-us/` , `/projects/*` ] ,
168
- appendScript : `src/custom-sw-code.js` ,
169
- debug : true ,
170
- workboxConfig : {
171
- importWorkboxFrom : `local` ,
172
- globDirectory : `rootDir` ,
173
- globPatterns : [ `a` , `b` , `c` ] ,
174
- modifyURLPrefix : {
175
- "/" : `pathPrefix/` ,
176
- } ,
177
- cacheId : `gatsby-plugin-offline` ,
178
- dontCacheBustURLsMatching : / ( \. j s $ | \. c s s $ | s t a t i c \/ ) / ,
179
- maximumFileSizeToCacheInBytes : 4800 ,
180
- runtimeCaching : [
181
- {
182
- urlPattern : / ( \. j s $ | \. c s s $ | s t a t i c \/ ) / ,
183
- handler : `CacheFirst` ,
184
- } ,
185
- {
186
- urlPattern : / ^ h t t p s ? : .* \/ p a g e - d a t a \/ .* \. j s o n / ,
187
- handler : `StaleWhileRevalidate` ,
188
- } ,
189
- {
190
- urlPattern :
191
- / ^ h t t p s ? : .* \. ( p n g | j p g | j p e g | w e b p | s v g | g i f | t i f f | j s | w o f f | w o f f 2 | j s o n | c s s ) $ / ,
192
- handler : `StaleWhileRevalidate` ,
193
- } ,
194
- {
195
- urlPattern : / ^ h t t p s ? : \/ \/ f o n t s \. g o o g l e a p i s \. c o m \/ c s s / ,
196
- handler : `StaleWhileRevalidate` ,
170
+ const { isValid, errors } = await testPluginOptionsSchema (
171
+ pluginOptionsSchema ,
172
+ {
173
+ precachePages : [ `/about-us/` , `/projects/*` ] ,
174
+ appendScript : `src/custom-sw-code.js` ,
175
+ debug : true ,
176
+ workboxConfig : {
177
+ importWorkboxFrom : `local` ,
178
+ globDirectory : `rootDir` ,
179
+ globPatterns : [ `a` , `b` , `c` ] ,
180
+ modifyURLPrefix : {
181
+ "/" : `pathPrefix/` ,
197
182
} ,
198
- ] ,
199
- skipWaiting : true ,
200
- clientsClaim : true ,
201
- } ,
202
- } )
183
+ cacheId : `gatsby-plugin-offline` ,
184
+ dontCacheBustURLsMatching : / ( \. j s $ | \. c s s $ | s t a t i c \/ ) / ,
185
+ maximumFileSizeToCacheInBytes : 4800 ,
186
+ runtimeCaching : [
187
+ {
188
+ urlPattern : / ( \. j s $ | \. c s s $ | s t a t i c \/ ) / ,
189
+ handler : `CacheFirst` ,
190
+ } ,
191
+ {
192
+ urlPattern : / ^ h t t p s ? : .* \/ p a g e - d a t a \/ .* \. j s o n / ,
193
+ handler : `StaleWhileRevalidate` ,
194
+ } ,
195
+ {
196
+ urlPattern :
197
+ / ^ h t t p s ? : .* \. ( p n g | j p g | j p e g | w e b p | s v g | g i f | t i f f | j s | w o f f | w o f f 2 | j s o n | c s s ) $ / ,
198
+ handler : `StaleWhileRevalidate` ,
199
+ } ,
200
+ {
201
+ urlPattern : / ^ h t t p s ? : \/ \/ f o n t s \. g o o g l e a p i s \. c o m \/ c s s / ,
202
+ handler : `StaleWhileRevalidate` ,
203
+ } ,
204
+ ] ,
205
+ skipWaiting : true ,
206
+ clientsClaim : true ,
207
+ } ,
208
+ }
209
+ )
203
210
204
211
expect ( isValid ) . toBe ( true )
212
+ expect ( errors ) . toEqual ( [ ] )
205
213
} )
206
214
} )
0 commit comments