diff options
Diffstat (limited to 'test/js/web/encoding/text-decoder.test.js')
-rw-r--r-- | test/js/web/encoding/text-decoder.test.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/js/web/encoding/text-decoder.test.js b/test/js/web/encoding/text-decoder.test.js index 8ec097f31..4991cf361 100644 --- a/test/js/web/encoding/text-decoder.test.js +++ b/test/js/web/encoding/text-decoder.test.js @@ -233,6 +233,20 @@ describe("TextDecoder", () => { }).toThrow(TypeError); }); + it("should not trim invalid byte sequences when fatal is false", () => { + const buf = Buffer.from([77, 97, 110, 32, 208, 129, 240, 164, 173]); + const received = new TextDecoder("utf-8").decode(buf); + const expected = "Man Ё\ufffd"; + expect(received).toBe(expected); + }); + + it("should trim when stream is true", () => { + const buf = Buffer.from([77, 97, 110, 32, 208, 129, 240, 164, 173]); + const received = new TextDecoder("utf-8").decode(buf, { stream: true }); + const expected = "Man Ё"; + expect(received).toBe(expected); + }); + it("constructor should set values", () => { const decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: false }); expect(decoder.fatal).toBe(true); |