diff options
author | Benjamin Gruenbaum <inglor@gmail.com> | 2020-11-02 01:57:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-02 10:57:18 +1100 |
commit | 9397cf508e57b8dac7d68b5469c1cca0618c6b10 (patch) | |
tree | a431a4c0d3bd4ea684e75536ee1aebf53c65060c /cli/tests/unit/text_encoding_test.ts | |
parent | d9b8778c4594b688ca47fe9eb5bfb288a93ca2a0 (diff) |
fix(op_crates/web): make TextEncoder work with forced non-strings (#8206)
Fixes: #8201
Diffstat (limited to 'cli/tests/unit/text_encoding_test.ts')
-rw-r--r-- | cli/tests/unit/text_encoding_test.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/cli/tests/unit/text_encoding_test.ts b/cli/tests/unit/text_encoding_test.ts index 4c5606a4f..189d391c5 100644 --- a/cli/tests/unit/text_encoding_test.ts +++ b/cli/tests/unit/text_encoding_test.ts @@ -210,3 +210,17 @@ unitTest(function toStringShouldBeWebCompatibility(): void { const decoder = new TextDecoder(); assertEquals(decoder.toString(), "[object TextDecoder]"); }); +unitTest(function textEncoderShouldCoerceToString(): void { + const encoder = new TextEncoder(); + const fixutreText = "text"; + const fixture = { + toString() { + return fixutreText; + }, + }; + + const bytes = encoder.encode(fixture as unknown as string); + const decoder = new TextDecoder(); + const decoded = decoder.decode(bytes); + assertEquals(decoded, fixutreText); +}); |