summaryrefslogtreecommitdiff
path: root/op_crates/web/text_encoding_test.js
diff options
context:
space:
mode:
Diffstat (limited to 'op_crates/web/text_encoding_test.js')
-rw-r--r--op_crates/web/text_encoding_test.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/op_crates/web/text_encoding_test.js b/op_crates/web/text_encoding_test.js
index f741fe409..06537df24 100644
--- a/op_crates/web/text_encoding_test.js
+++ b/op_crates/web/text_encoding_test.js
@@ -131,6 +131,44 @@ function textDecoderErrorEncoding() {
assert(didThrow);
}
+function textDecoderHandlesUndefined() {
+ const fixture = undefined;
+ const decoder = new TextDecoder();
+ assert(decoder.decode(fixture) === "");
+}
+
+function textDecoderThrowsOnEmpty() {
+ const fixture = "";
+ const decoder = new TextDecoder();
+ let didThrow = false;
+ try {
+ decoder.decode(fixture);
+ } catch (e) {
+ didThrow = true;
+ assert(
+ e.message ===
+ "Provided input is not of type ArrayBuffer or ArrayBufferView",
+ );
+ }
+ assert(didThrow);
+}
+
+function textDecoderThrowsOnNull() {
+ const fixture = null;
+ const decoder = new TextDecoder();
+ let didThrow = false;
+ try {
+ decoder.decode(fixture);
+ } catch (e) {
+ didThrow = true;
+ assert(
+ e.message ===
+ "Provided input is not of type ArrayBuffer or ArrayBufferView",
+ );
+ }
+ assert(didThrow);
+}
+
function textEncoder() {
const fixture = "𝓽𝓮𝔁𝓽";
const encoder = new TextEncoder();
@@ -231,6 +269,9 @@ function main() {
textDecoderNotBOM();
textDecoderASCII();
textDecoderErrorEncoding();
+ textDecoderHandlesUndefined();
+ textDecoderThrowsOnEmpty();
+ textDecoderThrowsOnNull();
textEncoder();
textEncodeInto();
textEncodeInto2();