File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments