Skip to content

Commit 402741f

Browse files
committed
adding tests
1 parent 3a18708 commit 402741f

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

ansi-styles/ansi-styles-tests.ts

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/// <reference path="ansi-styles.d.ts" />
2+
3+
import ansi = require('ansi-styles');
4+
5+
6+
var styles = [
7+
ansi.reset,
8+
9+
ansi.bold,
10+
ansi.dim,
11+
ansi.italic,
12+
ansi.underline,
13+
ansi.inverse,
14+
ansi.hidden,
15+
ansi.strikethrough,
16+
17+
ansi.black,
18+
ansi.red,
19+
ansi.green,
20+
ansi.yellow,
21+
ansi.blue,
22+
ansi.magenta,
23+
ansi.cyan,
24+
ansi.white,
25+
ansi.gray,
26+
27+
ansi.bgBlack,
28+
ansi.bgRed,
29+
ansi.bgGreen,
30+
ansi.bgYellow,
31+
ansi.bgBlue,
32+
ansi.bgMagenta,
33+
ansi.bgCyan,
34+
ansi.bgWhite
35+
]
36+
37+
for (var key in styles) {
38+
check(key, styles[key])
39+
}
40+
41+
function check(key:string, escapeCodes:ansi.EscapeCodePair): void {
42+
if (uninitialized(escapeCodes.open)) {
43+
throw new Error('key not found ~> ' + key + '.open')
44+
}
45+
if (uninitialized(escapeCodes.close)) {
46+
throw new Error('key not found ~> ' + key + '.close')
47+
}
48+
}
49+
50+
function uninitialized(val:any): boolean {
51+
return val === null || val === undefined
52+
}
53+
54+

0 commit comments

Comments
 (0)