-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.test.js
125 lines (118 loc) 路 2.75 KB
/
index.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import test from 'ava'
import ansiTo from '.'
const defaultColors = require('./colors/ansi-tag-html-colors-as-hex.json')
test('Plugin can load, override opts, and get ansi chunks', t => {
const MyPlugin = {
name: 'myplugin',
handler: (ansi, opts) => {
return {ansi, opts}
},
opts: {
myOpt1: 1337,
myOpt2: 'foo'
}
}
const handler = ansiTo.plugin(MyPlugin)
t.is(typeof handler, 'function')
const result = handler('abcd', {myOpt2: 'bar'})
t.deepEqual(result, {
ansi: {
raw: 'abcd',
textArea: {columns: 4, rows: 1},
plainText: 'abcd',
chunks: [{
type: 'text',
value: 'abcd',
position: {x: 0, y: 0, n: 0, raw: 0},
style: {}
}]
},
opts: {
myOpt1: 1337,
myOpt2: 'bar',
colors: defaultColors
}
})
})
test('Loads iTerm2Colors', t => {
const colors = ansiTo.load.iTerm2Colors('./colors/base16-flat-dark-f1lt3r-256.itermcolors')
t.deepEqual(colors, {
black: '#2c3e50',
red: '#ce4435',
green: '#2ecc71',
yellow: '#e9bd0e',
blue: '#318fce',
magenta: '#9b59b6',
cyan: '#1abc9c',
white: '#e0e0e0',
gray: '#758283',
blackBright: '#758283',
redBright: '#ff5342',
greenBright: '#39ff8d',
yellowBright: '#fedb00',
blueBright: '#0098ff',
magentaBright: '#e500ff',
cyanBright: '#00ffcc',
whiteBright: '#f9fdff',
bgBlack: '#2c3e50',
bgRed: '#ce4435',
bgGreen: '#2ecc71',
bgYellow: '#e9bd0e',
bgBlue: '#318fce',
bgMagenta: '#9b59b6',
bgCyan: '#1abc9c',
bgWhite: '#e0e0e0',
bgGray: '#758283',
bgBlackBright: '#758283',
bgRedBright: '#ff5342',
bgGreenBright: '#39ff8d',
bgYellowBright: '#fedb00',
bgBlueBright: '#0098ff',
bgMagentaBright: '#e500ff',
bgCyanBright: '#00ffcc',
bgWhiteBright: '#f9fdff',
backgroundColor: '#2c3e50',
foregroundColor: '#e0e0e0'
})
})
test('Can load color string', t => {
const colors = ansiTo.load.iTerm2Colors('./colors/base16-flat-dark-f1lt3r-256.itermcolors')
t.deepEqual(colors, {
black: '#2c3e50',
red: '#ce4435',
green: '#2ecc71',
yellow: '#e9bd0e',
blue: '#318fce',
magenta: '#9b59b6',
cyan: '#1abc9c',
white: '#e0e0e0',
gray: '#758283',
blackBright: '#758283',
redBright: '#ff5342',
greenBright: '#39ff8d',
yellowBright: '#fedb00',
blueBright: '#0098ff',
magentaBright: '#e500ff',
cyanBright: '#00ffcc',
whiteBright: '#f9fdff',
bgBlack: '#2c3e50',
bgRed: '#ce4435',
bgGreen: '#2ecc71',
bgYellow: '#e9bd0e',
bgBlue: '#318fce',
bgMagenta: '#9b59b6',
bgCyan: '#1abc9c',
bgWhite: '#e0e0e0',
bgGray: '#758283',
bgBlackBright: '#758283',
bgRedBright: '#ff5342',
bgGreenBright: '#39ff8d',
bgYellowBright: '#fedb00',
bgBlueBright: '#0098ff',
bgMagentaBright: '#e500ff',
bgCyanBright: '#00ffcc',
bgWhiteBright: '#f9fdff',
backgroundColor: '#2c3e50',
foregroundColor: '#e0e0e0'
})
})