diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-10-26 00:23:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-26 00:23:21 +0200 |
commit | ab0c33ebf83f25b526f732e3e07de5e75a6e69bb (patch) | |
tree | b4866d8dd8ae8998429e2fdc5375c0995d92be21 /cli/tests/unit/tty_test.ts | |
parent | af62e0833dbb23ac0af674b57e5938be97ad57c8 (diff) |
feat: Stabilize Deno.consoleSize() API (#15933)
This commit stabilizes "Deno.consoleSize()" API.
There is one change compared to previous unstable API,
in that the API doesn't accept any arguments. Console size
is established by querying syscalls for stdio streams at fd
0, 1 and 2.
Diffstat (limited to 'cli/tests/unit/tty_test.ts')
-rw-r--r-- | cli/tests/unit/tty_test.ts | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/cli/tests/unit/tty_test.ts b/cli/tests/unit/tty_test.ts index 8787db3e1..88b25d758 100644 --- a/cli/tests/unit/tty_test.ts +++ b/cli/tests/unit/tty_test.ts @@ -1,21 +1,15 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. -import { assert, assertThrows } from "./test_util.ts"; +import { assert } from "./test_util.ts"; // Note tests for Deno.stdin.setRaw is in integration tests. -Deno.test({ permissions: { read: true } }, function consoleSizeFile() { - const file = Deno.openSync("cli/tests/testdata/assets/hello.txt"); - assertThrows(() => { - Deno.consoleSize(file.rid); - }, Error); - file.close(); -}); - -Deno.test(function consoleSizeError() { - assertThrows(() => { - // Absurdly large rid. - Deno.consoleSize(0x7fffffff); - }, Deno.errors.BadResource); +Deno.test(function consoleSize() { + if (!Deno.isatty(Deno.stdout.rid)) { + return; + } + const result = Deno.consoleSize(); + assert(typeof result.columns !== "undefined"); + assert(typeof result.rows !== "undefined"); }); Deno.test({ permissions: { read: true } }, function isatty() { |