Skip to content

Commit 2f10583

Browse files
committed
test: validateDecoder()
1 parent 7392b63 commit 2f10583

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

test/30_helper.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
testB64URL,
2626
validateB64,
2727
validateB64URL,
28+
validateDecoder,
2829
validateEncoder,
2930
validB64Chars,
3031
validB64URLChars,
@@ -133,6 +134,30 @@ describe(filename, () => {
133134
})
134135
})
135136

137+
138+
describe('validateDecoder() works', () => {
139+
it('with valid input', () => {
140+
[1, 'a', {}, false, true, (void 0)].forEach(value => {
141+
assert(typeof validateDecoder(value) === 'undefined')
142+
})
143+
})
144+
145+
it('with invalid input', () => {
146+
try {
147+
// @ts-ignore
148+
validateDecoder(null)
149+
assert(false, 'Should throw error, but NOT')
150+
}
151+
catch (ex) {
152+
assert(
153+
ex.message && ex.message.includes(ErrMsg.textDecoderUndefined),
154+
ex.message,
155+
)
156+
}
157+
})
158+
})
159+
160+
136161
describe('parseTextDecoder() works', () => {
137162
it('with valid input', () => {
138163
const ret = parseTextDecoder(NodeTextDecoder)

0 commit comments

Comments
 (0)