summaryrefslogtreecommitdiff
path: root/cli/tests/unit/text_encoding_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/unit/text_encoding_test.ts')
-rw-r--r--cli/tests/unit/text_encoding_test.ts14
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);
+});