Skip to content

Commit 1e2d625

Browse files
committed
test: update cased of parseTextEncoder(), parseTextDecoder()
1 parent 2745e26 commit 1e2d625

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

test/30_helper.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,23 @@ describe(filename, () => {
105105
else { // node.js v11+
106106
const ret = parseTextEncoder()
107107
assert(ret === NodeTextEncoder)
108+
109+
// @ts-ignore
110+
const orig = global.TextEncoder
111+
try {
112+
// @ts-ignore
113+
global.TextEncoder = null
114+
parseTextEncoder()
115+
assert(false, 'Should throw error, but NOT')
116+
}
117+
catch (ex) {
118+
// @ts-ignore
119+
global.TextEncoder = orig
120+
assert(
121+
ex.message && ex.message.includes(ErrMsg.textEncoderUndefined),
122+
ex.message,
123+
)
124+
}
108125
}
109126
})
110127

@@ -154,6 +171,23 @@ describe(filename, () => {
154171
else { // node.js v11+
155172
const ret = parseTextDecoder()
156173
assert(ret === NodeTextDecoder)
174+
175+
// @ts-ignore
176+
const orig = global.TextDecoder
177+
try {
178+
// @ts-ignore
179+
global.TextDecoder = null
180+
parseTextDecoder()
181+
assert(false, 'Should throw error, but NOT')
182+
}
183+
catch (ex) {
184+
// @ts-ignore
185+
global.TextDecoder = orig
186+
assert(
187+
ex.message && ex.message.includes(ErrMsg.textDecoderUndefined),
188+
ex.message,
189+
)
190+
}
157191
}
158192
})
159193

0 commit comments

Comments
 (0)