aboutsummaryrefslogtreecommitdiff
path: root/test/js/web/encoding/text-decoder.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/js/web/encoding/text-decoder.test.js')
-rw-r--r--test/js/web/encoding/text-decoder.test.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/js/web/encoding/text-decoder.test.js b/test/js/web/encoding/text-decoder.test.js
index abd4c2a72..d8038e628 100644
--- a/test/js/web/encoding/text-decoder.test.js
+++ b/test/js/web/encoding/text-decoder.test.js
@@ -225,6 +225,25 @@ describe("TextDecoder", () => {
expect(decoder.decode(bytes.subarray(0, amount.written))).toBe(text);
gcTrace(true);
});
+
+ it("should respect fatal when encountering invalid data", () => {
+ const decoder = new TextDecoder("utf-8", { fatal: true });
+ expect(() => {
+ decoder.decode(new Uint8Array([0xC0])) // Invalid UTF8
+ }).toThrow(TypeError);
+ });
+
+ it("constructor should set values", () => {
+ const decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: false });
+ expect(decoder.fatal).toBe(true);
+ // expect(decoder.ignoreBOM).toBe(false); // currently the getter for ignoreBOM doesn't work and always returns undefined
+ });
+
+ it("should throw on invalid input", () => {
+ expect(() => {
+ const decoder = new TextDecoder("utf-8", { fatal: 10, ignoreBOM: {} });
+ }).toThrow();
+ });
});
it("truncated sequences", () => {