Skip to content

Commit 47dc761

Browse files
committed
fix utils tests
1 parent df4a8f8 commit 47dc761

File tree

1 file changed

+120
-6
lines changed

1 file changed

+120
-6
lines changed

test/utils.spec.js

Lines changed: 120 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,43 +191,117 @@ test('throw error if options are invalid – client.clientId', (t) => {
191191

192192
test('throw error if options are invalid – cache', (t) => {
193193
t.throws(() => utils.verify({
194+
client: {
195+
clientId: 'foobar',
196+
realmUrl: 'http://foobar.com'
197+
},
194198
cache: null
195199
}), Error)
196200

197201
t.throws(() => utils.verify({
198-
cache: undefined
199-
}), Error)
200-
201-
t.throws(() => utils.verify({
202+
client: {
203+
clientId: 'foobar',
204+
realmUrl: 'http://foobar.com'
205+
},
202206
cache: NaN
203207
}), Error)
204208

205209
t.throws(() => utils.verify({
210+
client: {
211+
clientId: 'foobar',
212+
realmUrl: 'http://foobar.com'
213+
},
206214
cache: ''
207215
}), Error)
208216

209217
t.throws(() => utils.verify({
218+
client: {
219+
clientId: 'foobar',
220+
realmUrl: 'http://foobar.com'
221+
},
210222
cache: 'foobar'
211223
}), Error)
212224

213225
t.throws(() => utils.verify({
226+
client: {
227+
clientId: 'foobar',
228+
realmUrl: 'http://foobar.com'
229+
},
214230
cache: 42
215231
}), Error)
216232

217233
t.throws(() => utils.verify({
234+
client: {
235+
clientId: 'foobar',
236+
realmUrl: 'http://foobar.com'
237+
},
218238
cache: true
219239
}), Error)
220240

221241
t.throws(() => utils.verify({
242+
client: {
243+
clientId: 'foobar',
244+
realmUrl: 'http://foobar.com'
245+
},
222246
cache: []
223247
}), Error)
248+
})
224249

250+
test('throw error if options are invalid – userInfo', (t) => {
225251
t.throws(() => utils.verify({
226-
cache: new RegExp()
252+
client: {
253+
clientId: 'foobar',
254+
realmUrl: 'http://foobar.com'
255+
},
256+
cache: null
227257
}), Error)
228258

229259
t.throws(() => utils.verify({
230-
cache: {}
260+
client: {
261+
clientId: 'foobar',
262+
realmUrl: 'http://foobar.com'
263+
},
264+
cache: NaN
265+
}), Error)
266+
267+
t.throws(() => utils.verify({
268+
client: {
269+
clientId: 'foobar',
270+
realmUrl: 'http://foobar.com'
271+
},
272+
cache: ''
273+
}), Error)
274+
275+
t.throws(() => utils.verify({
276+
client: {
277+
clientId: 'foobar',
278+
realmUrl: 'http://foobar.com'
279+
},
280+
cache: 'foobar'
281+
}), Error)
282+
283+
t.throws(() => utils.verify({
284+
client: {
285+
clientId: 'foobar',
286+
realmUrl: 'http://foobar.com'
287+
},
288+
cache: 42
289+
}), Error)
290+
291+
t.throws(() => utils.verify({
292+
client: {
293+
clientId: 'foobar',
294+
realmUrl: 'http://foobar.com'
295+
},
296+
cache: true
297+
}), Error)
298+
299+
t.throws(() => utils.verify({
300+
client: {
301+
clientId: 'foobar',
302+
realmUrl: 'http://foobar.com'
303+
},
304+
cache: [42]
231305
}), Error)
232306
})
233307

@@ -239,6 +313,22 @@ test('throw no error if options are valid', (t) => {
239313
}
240314
}), Error)
241315

316+
t.notThrows(() => utils.verify({
317+
client: {
318+
clientId: 'foobar',
319+
realmUrl: 'http://foobar.com'
320+
},
321+
cache: undefined
322+
}), Error)
323+
324+
t.notThrows(() => utils.verify({
325+
client: {
326+
clientId: 'foobar',
327+
realmUrl: 'http://foobar.com'
328+
},
329+
cache: {}
330+
}), Error)
331+
242332
t.notThrows(() => utils.verify({
243333
client: {
244334
clientId: fixtures.clientId,
@@ -256,4 +346,28 @@ test('throw no error if options are valid', (t) => {
256346
},
257347
cache: false
258348
}), Error)
349+
350+
t.notThrows(() => utils.verify({
351+
client: {
352+
clientId: 'foobar',
353+
realmUrl: 'http://foobar.com'
354+
},
355+
userInfo: undefined
356+
}), Error)
357+
358+
t.notThrows(() => utils.verify({
359+
client: {
360+
clientId: 'foobar',
361+
realmUrl: 'http://foobar.com'
362+
},
363+
userInfo: []
364+
}), Error)
365+
366+
t.notThrows(() => utils.verify({
367+
client: {
368+
clientId: 'foobar',
369+
realmUrl: 'http://foobar.com'
370+
},
371+
userInfo: ['string']
372+
}), Error)
259373
})

0 commit comments

Comments
 (0)