1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00
denoland-deno/cli/tests/unit/tty_test.ts
Luca Casonato 70bc0eb72b
feat(unstable): Deno.setRaw -> Deno.stdin.setRaw (#15797)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-09-28 15:03:56 +02:00

38 lines
1 KiB
TypeScript

// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
import { assert, assertThrows } 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({ permissions: { read: true } }, function isatty() {
// CI not under TTY, so cannot test stdin/stdout/stderr.
const f = Deno.openSync("cli/tests/testdata/assets/hello.txt");
assert(!Deno.isatty(f.rid));
f.close();
});
Deno.test(function isattyError() {
let caught = false;
try {
// Absurdly large rid.
Deno.isatty(0x7fffffff);
} catch (e) {
caught = true;
assert(e instanceof Deno.errors.BadResource);
}
assert(caught);
});