Files
Filip Skokan eebee55a01 refactor: restructure src/lib and src/runtime now that runtime is fixed
BREAKING CHANGE: createRemoteJWKSet now uses fetch, because of that its Node.js only options.agent property has been removed and new fetch-related options were added
2025-02-22 15:16:04 +01:00

30 lines
597 B
TypeScript

import test from 'ava'
import { createLocalJWKSet } from '../../src/index.js'
test('LocalJWKSet', async (t) => {
for (const f of [
null,
{},
{ keys: null },
{ keys: {} },
{ keys: [null] },
{ keys: [0] },
{ keys: [undefined] },
{ keys: [[]] },
1,
Boolean,
]) {
t.throws(() => createLocalJWKSet(f), { code: 'ERR_JWKS_INVALID' })
}
const jwks = { keys: [] }
const set = createLocalJWKSet(jwks)
const clone = set.jwks()
t.false(clone === jwks)
t.false(clone === set.jwks())
t.deepEqual(clone, jwks)
t.deepEqual(clone, set.jwks())
})