Skip to content

Commit 8d8cbd8

Browse files
committed
terminal windows ok
1 parent 4dea309 commit 8d8cbd8

File tree

1 file changed

+42
-6
lines changed

1 file changed

+42
-6
lines changed

test/terminal.test.js

+42-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const { test } = require('brittle')
44
const { isWindows } = require('which-runtime')
5-
// TODO: fix tests for Windows
65

76
const dirname = __dirname
87
global.Pear = null
@@ -64,13 +63,30 @@ test('usage.footer content', async function (t) {
6463
t.ok(usage.footer.help.includes('Welcome to the IoP'), 'usage.footer.help should contain welcome message')
6564
})
6665

67-
test('ansi formatting functions', { skip: isWindows }, async function (t) {
68-
t.plan(10)
66+
test('ansi formatting functions', async function (t) {
67+
t.plan(14)
6968

7069
const { teardown } = rig()
7170
t.teardown(teardown)
7271

7372
const { ansi } = require('../terminal')
73+
if (isWindows) {
74+
t.is(ansi.bold('text'), 'text', 'ansi.bold should format text correctly')
75+
t.is(ansi.dim('text'), 'text', 'ansi.dim should format text correctly')
76+
t.is(ansi.italic('text'), 'text', 'ansi.italic should format text correctly')
77+
t.is(ansi.underline('text'), 'text', 'ansi.underline should format text correctly')
78+
t.is(ansi.inverse('text'), 'text', 'ansi.inverse should format text correctly')
79+
t.is(ansi.red('text'), 'text', 'ansi.red should format text correctly')
80+
t.is(ansi.green('text'), 'text', 'ansi.green should format text correctly')
81+
t.is(ansi.yellow('text'), 'text', 'ansi.yellow should format text correctly')
82+
t.is(ansi.gray('text'), 'text', 'ansi.gray should format text correctly')
83+
t.is(ansi.upHome(), '', 'ansi.upHome should format text correctly')
84+
t.is(ansi.link('text'), 'text', 'ansi.link should format text correctly')
85+
t.is(ansi.hideCursor(), '', 'ansi.hideCursor should format text correctly')
86+
t.is(ansi.showCursor(), '', 'ansi.showCursor should format text correctly')
87+
return
88+
}
89+
7490
t.is(ansi.bold('text'), '\x1B[1mtext\x1B[22m', 'ansi.bold should format text correctly')
7591
t.is(ansi.dim('text'), '\x1B[2mtext\x1B[22m', 'ansi.dim should format text correctly')
7692
t.is(ansi.italic('text'), '\x1B[3mtext\x1B[23m', 'ansi.italic should format text correctly')
@@ -80,25 +96,45 @@ test('ansi formatting functions', { skip: isWindows }, async function (t) {
8096
t.is(ansi.green('text'), '\x1B[32mtext\x1B[39m', 'ansi.green should format text correctly')
8197
t.is(ansi.yellow('text'), '\x1B[33mtext\x1B[39m', 'ansi.yellow should format text correctly')
8298
t.is(ansi.gray('text'), '\x1B[90mtext\x1B[39m', 'ansi.gray should format text correctly')
99+
t.is(ansi.upHome(), '\x1B[1F', 'ansi.upHome should format text correctly')
100+
t.is(ansi.upHome(35), '\x1B[35F', 'ansi.upHome should format text correctly')
101+
t.is(ansi.link('url', 'text'), '\x1B]8;;url\x07text\x1B]8;;\x07', 'ansi.link should format text correctly')
83102
t.is(ansi.hideCursor(), '\x1B[?25l', 'ansi.hideCursor should format text correctly')
103+
t.is(ansi.showCursor(), '\x1B[?25h', 'ansi.showCursor should format text correctly')
84104
})
85105

86-
test('ansi special characters', { skip: isWindows }, async function (t) {
87-
t.plan(8)
106+
test('ansi special characters', async function (t) {
107+
t.plan(9)
88108

89109
const { teardown } = rig()
90110
t.teardown(teardown)
91111

92112
const { ansi } = require('../terminal')
113+
114+
if (isWindows) {
115+
t.is(ansi.sep, '-', 'ansi.sep should be formatted correctly')
116+
t.is(ansi.tick, '^', 'ansi.tick should be formatted correctly')
117+
t.is(ansi.cross, 'x', 'ansi.cross should be formatted correctly')
118+
t.is(ansi.warning, '!', 'ansi.warning should be formatted correctly')
119+
t.is(ansi.pear, '*', 'ansi.pear should be formatted correctly')
120+
t.is(ansi.dot, '•', 'ansi.dot should be formatted correctly')
121+
t.is(ansi.key, '>', 'ansi.key should be formatted correctly')
122+
t.is(ansi.down, '↓', 'ansi.down should be formatted correctly')
123+
t.is(ansi.up, '↑', 'ansi.up should be formatted correctly')
124+
return
125+
}
126+
93127
t.is(ansi.sep, ansi.dim(ansi.green('∞')), 'ansi.sep should be formatted correctly')
94128
t.is(ansi.tick, ansi.green('✔'), 'ansi.tick should be formatted correctly')
95129
t.is(ansi.cross, ansi.red('✖'), 'ansi.cross should be formatted correctly')
96130
t.is(ansi.warning, '⚠️', 'ansi.warning should be formatted correctly')
97131
t.is(ansi.pear, '🍐', 'ansi.pear should be formatted correctly')
98132
t.is(ansi.dot, 'o', 'ansi.dot should be formatted correctly')
99133
t.is(ansi.key, '🔑', 'ansi.key should be formatted correctly')
100-
t.is(ansi.upHome(2), '\x1B[2F', 'ansi.upHome should format text correctly')
134+
t.is(ansi.down, '⬇', 'ansi.down should be formatted correctly')
135+
t.is(ansi.up, '⬆', 'ansi.up should be formatted correctly')
101136
})
137+
102138
test('indicator function', async function (t) {
103139
t.plan(6)
104140

0 commit comments

Comments
 (0)