2
2
3
3
const { test } = require ( 'brittle' )
4
4
const { isWindows } = require ( 'which-runtime' )
5
- // TODO: fix tests for Windows
6
5
7
6
const dirname = __dirname
8
7
global . Pear = null
@@ -64,13 +63,30 @@ test('usage.footer content', async function (t) {
64
63
t . ok ( usage . footer . help . includes ( 'Welcome to the IoP' ) , 'usage.footer.help should contain welcome message' )
65
64
} )
66
65
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 )
69
68
70
69
const { teardown } = rig ( )
71
70
t . teardown ( teardown )
72
71
73
72
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
+
74
90
t . is ( ansi . bold ( 'text' ) , '\x1B[1mtext\x1B[22m' , 'ansi.bold should format text correctly' )
75
91
t . is ( ansi . dim ( 'text' ) , '\x1B[2mtext\x1B[22m' , 'ansi.dim should format text correctly' )
76
92
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) {
80
96
t . is ( ansi . green ( 'text' ) , '\x1B[32mtext\x1B[39m' , 'ansi.green should format text correctly' )
81
97
t . is ( ansi . yellow ( 'text' ) , '\x1B[33mtext\x1B[39m' , 'ansi.yellow should format text correctly' )
82
98
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' )
83
102
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' )
84
104
} )
85
105
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 )
88
108
89
109
const { teardown } = rig ( )
90
110
t . teardown ( teardown )
91
111
92
112
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
+
93
127
t . is ( ansi . sep , ansi . dim ( ansi . green ( '∞' ) ) , 'ansi.sep should be formatted correctly' )
94
128
t . is ( ansi . tick , ansi . green ( '✔' ) , 'ansi.tick should be formatted correctly' )
95
129
t . is ( ansi . cross , ansi . red ( '✖' ) , 'ansi.cross should be formatted correctly' )
96
130
t . is ( ansi . warning , '⚠️' , 'ansi.warning should be formatted correctly' )
97
131
t . is ( ansi . pear , '🍐' , 'ansi.pear should be formatted correctly' )
98
132
t . is ( ansi . dot , 'o' , 'ansi.dot should be formatted correctly' )
99
133
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' )
101
136
} )
137
+
102
138
test ( 'indicator function' , async function ( t ) {
103
139
t . plan ( 6 )
104
140
0 commit comments