This repository has been archived by the owner on Aug 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathconfig.js
152 lines (127 loc) · 3.72 KB
/
config.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
'use strict';
const assert = require('assert');
const config = require('@emmetio/config');
const expand = require('../').expand;
const sampleConfig = require('./sample-config.json');
describe('Config support', () => {
describe('Markup', () => {
it('globals', () => {
const conf = config(sampleConfig, { syntax: 'html' });
assert.equal(
expand('.test', conf),
'<DIV CLASS="test"></DIV>\n<!-- /.test -->',
'Use markup format and profile options'
);
assert.equal(
expand('.foo>.-bar', conf),
'<DIV CLASS="foo">\n\t<DIV CLASS="foo_elbar"></DIV>\n\t<!-- /.foo_elbar -->\n</DIV>\n<!-- /.foo -->',
'Use markup BEM options'
);
assert.equal(
expand('[lang="${lang}" foo=${bar}]', conf),
'<DIV LANG="ru" FOO="bar"></DIV>',
'Use markup variables'
);
assert.equal(
expand('sw>a>img', conf),
'<SW><A HREF="" TITLE=""><IMG SRC="" ALT=""></A></SW>',
'Use markup & default snippets'
);
});
it('syntax', () => {
const conf = config(sampleConfig, { syntax: 'angular' });
assert.equal(
expand('.test', conf),
'<div CLASSNAME="test"></div>',
'Use markup format and profile options, override with syntax format & options'
);
assert.equal(
expand('sw>a>img', conf),
'<div NGSWITCH=""><a HREF="" TITLE=""><img SRC="" ALT=""></a></div>',
'Use markup snippets, override with syntax snippets'
);
});
it('project', () => {
const conf = config(sampleConfig, {
syntax: 'angular',
project: 'proj1'
});
// NB even if `tagCase` is set to "upper", syntax-specific config
// takes precedence over type-specific, defined in project
assert.equal(
expand('.foo>.-bar', conf),
'<div CLASSNAME="foo"><div CLASSNAME="foo_elbar"></div></div>',
'Use markup format & syntax config, disable formatting in project'
);
assert.equal(
expand('p1s>sw>a>img', conf),
'<div CLASSNAME="proj1-snippet"><div NGSWITCH=""><a HREF="" TITLE=""><img SRC="" ALT=""></a></div></div>',
'Use markup & syntax snippets, add from project globals'
);
});
});
describe('Stylesheet', () => {
it('globals', () => {
const conf = config(sampleConfig, { type: 'stylesheet' });
assert.equal(
expand('c', conf),
'COLOR:#000;',
'Use stylesheet format and profile options'
);
assert.equal(
expand('c+bg#fc0', conf),
'COLOR:#000;BACKGROUND:#fc0;',
'Use stylesheet format and profile options'
);
assert.equal(
expand('p10+gd', conf),
'PADDING:10px;GRID:;',
'Use stylesheet & default snippets'
);
});
it('syntax', () => {
const conf = config(sampleConfig, { syntax: 'sugarss' });
assert.equal(
expand('c', conf),
'COLOR #000',
'Use stylesheet format and profile options, override with syntax'
);
assert.equal(
expand('c+bg#fc0', conf),
'COLOR #000BACKGROUND #fc0',
'Use stylesheet format and profile options, override with syntax'
);
assert.equal(
expand('p10+gd+foo', conf),
'PADDING 10pxGRID BAR ',
'Use stylesheet & default snippets, override with syntax'
);
});
it('project', () => {
const conf = config(sampleConfig, {
syntax: 'sugarss',
project: 'proj1'
});
assert.equal(
expand('c', conf),
'COLOR #000;;',
'Use global & syntax format and profile options, override with project'
);
assert.equal(
expand('c+bg#fc0', conf),
'COLOR #000;;BACKGROUND #fc0;;',
'Use global & syntax format and profile options, override with project'
);
assert.equal(
expand('gd+foo', conf),
'BAZ ;;BAR ;;',
'Use global & syntax snippets, override with project'
);
assert.equal(
expand('p10+m5a', conf),
'PADDING 10cm;;MARGIN 5bbbb;;',
'Override options with project'
);
});
});
});