-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
test.js
30 lines (26 loc) · 837 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import process from 'node:process';
import test from 'ava';
import {execa} from 'execa';
import terminalSize from './index.js';
test('main', t => {
const size = terminalSize();
console.log('Main size:', size);
t.true(size.columns > 0);
t.true(size.rows > 0);
});
test('child', async t => {
const {stdout} = await execa('node', ['fixture.js']);
const [columns, rows] = stdout.split('\n').map(line => Number.parseInt(line, 10));
console.log('Child size:', {columns, rows});
t.true(Number.parseInt(columns, 10) > 0);
t.true(Number.parseInt(rows, 10) > 0);
});
test('no TERM environment variable', t => {
const envTerm = process.env.TERM;
process.env.TERM = undefined;
const size = terminalSize();
process.env.TERM = envTerm;
console.log('Size with no $TERM:', size);
t.true(size.columns > 0);
t.true(size.rows > 0);
});