|
1
|
|
|
import {expect} from 'chai'; |
|
2
|
|
|
import Parser from '../../src/lib/icls-parser'; |
|
3
|
|
|
import * as samples from '../samples/icls-strings'; |
|
4
|
|
|
|
|
5
|
|
|
describe('Parser.parse', () => { |
|
6
|
|
|
let parser; |
|
7
|
|
|
beforeEach(() => { |
|
8
|
|
|
parser = new Parser(); |
|
9
|
|
|
}); |
|
10
|
|
|
|
|
11
|
|
|
it('should return an object with the name', () => { |
|
12
|
|
|
const parsed = parser.parse(samples.schemeNode).toJS(); |
|
13
|
|
|
|
|
14
|
|
|
expect(parsed).to.have.property('name', 'Material Peacock Optimized'); |
|
15
|
|
|
expect(parsed).to.have.property('version', 142); |
|
16
|
|
|
}); |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
it('should return an object with the first level options', () => { |
|
20
|
|
|
const parsed = parser.parse(samples.firstLevelOptionsNode).toJS(); |
|
21
|
|
|
|
|
22
|
|
|
expect(parsed).to.have.property('name', 'Material Peacock Optimized'); |
|
23
|
|
|
expect(parsed).to.have.property('version', 142); |
|
24
|
|
|
expect(parsed).to.have.property('font_scale', 1.0); |
|
25
|
|
|
expect(parsed).to.have.property('line_spacing', 1.2); |
|
26
|
|
|
expect(parsed).to.have.property('editor_font_size', 12); |
|
27
|
|
|
expect(parsed).to.have.property('editor_font_name', 'Fira Code'); |
|
28
|
|
|
expect(parsed).to.have.property('editor_ligatures', true); |
|
29
|
|
|
expect(parsed).to.have.property('console_font_name', 'Menlo'); |
|
30
|
|
|
expect(parsed).to.have.property('console_line_spacing', 1.4); |
|
31
|
|
|
|
|
32
|
|
|
}); |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
it('should return an object with the colors', () => { |
|
36
|
|
|
const parsed = parser.parse(samples.colorsNode).toJS(); |
|
37
|
|
|
|
|
38
|
|
|
expect(parsed).to.have.property('colors'); |
|
39
|
|
|
expect(parsed.colors).to.have.property('added_lines_color', '#5f7210'); |
|
40
|
|
|
expect(parsed.colors).to.have.property('annotations_color', '#8b999f'); |
|
41
|
|
|
expect(parsed.colors).to.have.property('caret_color', '#60999d'); |
|
42
|
|
|
expect(parsed.colors).to.have.property('caret_row_color', '#0c1418'); |
|
43
|
|
|
expect(parsed.colors).to.have.property('console_background_key', ''); |
|
44
|
|
|
}); |
|
45
|
|
|
|
|
46
|
|
|
it('should handle the attribute tag with it\'s sub-childs', () => { |
|
47
|
|
|
const parsed = parser.parse(samples.attributesNode).toJS(); |
|
48
|
|
|
|
|
49
|
|
|
expect(parsed).to.have.property('bnf_illegal'); |
|
50
|
|
|
expect(parsed.bnf_illegal).to.have.property('foreground', '#d0d0ff'); |
|
51
|
|
|
expect(parsed).to.have.property('bnf_keyword'); |
|
52
|
|
|
expect(parsed.bnf_keyword).to.have.property('foreground', '#bbb529'); |
|
53
|
|
|
expect(parsed.bnf_keyword).to.have.property('background', '#629755'); |
|
54
|
|
|
}); |
|
55
|
|
|
|
|
56
|
|
|
it('should handle the attribute tag with it\'s sub-childs and deep keys', () => { |
|
57
|
|
|
const parsed = parser.parse(samples.attributesNodeWithDeepKeys).toJS(); |
|
58
|
|
|
|
|
59
|
|
|
expect(parsed).to.have.property('bash'); |
|
60
|
|
|
expect(parsed.bash).to.have.property('here_doc'); |
|
61
|
|
|
expect(parsed.bash.here_doc).to.have.property('background', '#4b694c'); |
|
62
|
|
|
expect(parsed.bash.here_doc).to.have.property('foreground', '#bc1d36'); |
|
63
|
|
|
|
|
64
|
|
|
expect(parsed.bash).to.have.property('internal_command'); |
|
65
|
|
|
expect(parsed.bash.internal_command).to.have.property('foreground', '#2544ff'); |
|
66
|
|
|
}); |
|
67
|
|
|
|
|
68
|
|
|
it('shouldn\'t break with an unexpected object', () => { |
|
69
|
|
|
const parsed = parser.parse(samples.unexpectedObject).toJS(); |
|
70
|
|
|
|
|
71
|
|
|
expect(parsed).to.have.property('font_scale', 1); |
|
72
|
|
|
expect(parsed).to.have.property('colors'); |
|
73
|
|
|
expect(parsed.colors).to.have.property('annotations_color', '#8b999f'); |
|
74
|
|
|
}); |
|
75
|
|
|
}); |
|
76
|
|
|
|