summaryrefslogtreecommitdiff
path: root/js/text_encoding_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'js/text_encoding_test.ts')
-rw-r--r--js/text_encoding_test.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/js/text_encoding_test.ts b/js/text_encoding_test.ts
index 402044e36..efb841fc6 100644
--- a/js/text_encoding_test.ts
+++ b/js/text_encoding_test.ts
@@ -48,6 +48,23 @@ test(function textDecoder2() {
assertEqual(decoder.decode(fixture), "𝓽𝓮𝔁𝓽");
});
+test(function textDecoderASCII() {
+ const fixture = new Uint8Array([0x89, 0x95, 0x9f, 0xbf]);
+ const decoder = new TextDecoder("ascii");
+ assertEqual(decoder.decode(fixture), "‰•Ÿ¿");
+});
+
+test(function textDecoderErrorEncoding() {
+ let didThrow = false;
+ try {
+ const decoder = new TextDecoder("foo");
+ } catch (e) {
+ didThrow = true;
+ assertEqual(e.message, "The encoding label provided ('foo') is invalid.");
+ }
+ assert(didThrow);
+});
+
test(function textEncoder() {
const fixture = "������";
const encoder = new TextEncoder();