@@ -133,72 +133,78 @@ describe(`pluginOptionsSchema`, () => {
133
133
`"workboxConfig.clientsClaim" must be a boolean` ,
134
134
]
135
135
136
- const { isValid, 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
162
165
expect ( isValid ) . toBe ( false )
163
166
expect ( errors ) . toEqual ( expectedErrors )
164
167
} )
165
168
166
169
it ( `should validate the schema` , async ( ) => {
167
- const { isValid, errors } = await testPluginOptionsSchema ( pluginOptionsSchema , {
168
- precachePages : [ `/about-us/` , `/projects/*` ] ,
169
- appendScript : `src/custom-sw-code.js` ,
170
- debug : true ,
171
- workboxConfig : {
172
- importWorkboxFrom : `local` ,
173
- globDirectory : `rootDir` ,
174
- globPatterns : [ `a` , `b` , `c` ] ,
175
- modifyURLPrefix : {
176
- "/" : `pathPrefix/` ,
177
- } ,
178
- cacheId : `gatsby-plugin-offline` ,
179
- dontCacheBustURLsMatching : / ( \. j s $ | \. c s s $ | s t a t i c \/ ) / ,
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 : / ^ 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 ) $ / ,
191
- handler : `StaleWhileRevalidate` ,
192
- } ,
193
- {
194
- 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 / ,
195
- 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/` ,
196
182
} ,
197
- ] ,
198
- skipWaiting : true ,
199
- clientsClaim : true ,
200
- } ,
201
- } )
183
+ cacheId : `gatsby-plugin-offline` ,
184
+ dontCacheBustURLsMatching : / ( \. j s $ | \. c s s $ | s t a t i c \/ ) / ,
185
+ runtimeCaching : [
186
+ {
187
+ urlPattern : / ( \. j s $ | \. c s s $ | s t a t i c \/ ) / ,
188
+ handler : `CacheFirst` ,
189
+ } ,
190
+ {
191
+ urlPattern : / ^ h t t p s ? : .* \/ p a g e - d a t a \/ .* \. j s o n / ,
192
+ handler : `StaleWhileRevalidate` ,
193
+ } ,
194
+ {
195
+ urlPattern : / ^ 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 ) $ / ,
196
+ handler : `StaleWhileRevalidate` ,
197
+ } ,
198
+ {
199
+ 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 / ,
200
+ handler : `StaleWhileRevalidate` ,
201
+ } ,
202
+ ] ,
203
+ skipWaiting : true ,
204
+ clientsClaim : true ,
205
+ } ,
206
+ }
207
+ )
202
208
203
209
expect ( isValid ) . toBe ( true )
204
210
expect ( errors ) . toEqual ( [ ] )
0 commit comments