jose/test/unit/check_iv_length.test.mjs

12 lines
438 B
JavaScript

import test from 'ava'
const root = !('WEBCRYPTO' in process.env) ? '#dist' : '#dist/webcrypto'
const { default: checkIvLength } = await import(`${root}/lib/check_iv_length`)
test('lib/check_iv_length.ts', (t) => {
t.throws(() => checkIvLength('A256GCM', new Uint8Array(13)), {
code: 'ERR_JWE_INVALID',
message: 'Invalid Initialization Vector length',
})
t.notThrows(() => checkIvLength('A256GCM', new Uint8Array(12)))
})