summaryrefslogtreecommitdiff
path: root/cli/tests/unit/text_encoding_test.ts
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2023-11-13 11:35:48 -0700
committerGitHub <noreply@github.com>2023-11-13 11:35:48 -0700
commit65b9150f83033602639957d01a5a4d35b3d2c1da (patch)
treea3060043d663d02505f6e22b18e44ea42c61ce65 /cli/tests/unit/text_encoding_test.ts
parent25950baed347fa2311ecd59ae569a5d3ab4851f5 (diff)
chore(ext/web): use a non-resource stream for textDecoderStreamCleansUpOnCancel (#21181)
Follow-up fix to #21074
Diffstat (limited to 'cli/tests/unit/text_encoding_test.ts')
-rw-r--r--cli/tests/unit/text_encoding_test.ts20
1 files changed, 16 insertions, 4 deletions
diff --git a/cli/tests/unit/text_encoding_test.ts b/cli/tests/unit/text_encoding_test.ts
index 270fd07a8..71fcc1cf0 100644
--- a/cli/tests/unit/text_encoding_test.ts
+++ b/cli/tests/unit/text_encoding_test.ts
@@ -1,5 +1,10 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-import { assert, assertEquals, assertThrows } from "./test_util.ts";
+import {
+ assert,
+ assertEquals,
+ assertStrictEquals,
+ assertThrows,
+} from "./test_util.ts";
Deno.test(function btoaSuccess() {
const text = "hello world";
@@ -323,9 +328,15 @@ Deno.test(function binaryEncode() {
Deno.test(
{ permissions: { read: true } },
async function textDecoderStreamCleansUpOnCancel() {
- const filename = "cli/tests/testdata/assets/hello.txt";
- const file = await Deno.open(filename);
- const readable = file.readable.pipeThrough(new TextDecoderStream());
+ let cancelled = false;
+ const readable = new ReadableStream({
+ start: (controller) => {
+ controller.enqueue(new Uint8Array(12));
+ },
+ cancel: () => {
+ cancelled = true;
+ },
+ }).pipeThrough(new TextDecoderStream());
const chunks = [];
for await (const chunk of readable) {
chunks.push(chunk);
@@ -334,5 +345,6 @@ Deno.test(
}
assertEquals(chunks.length, 1);
assertEquals(chunks[0].length, 12);
+ assertStrictEquals(cancelled, true);
},
);