forked from dan-gamble/postcss-font-awesome
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.js
72 lines (61 loc) · 2.54 KB
/
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
import postcss from 'postcss';
import test from 'ava';
import plugin from './';
function run(t, input, output, opts = {}) {
return postcss([plugin(opts)]).process(input)
.then(result => {
t.deepEqual(result.css, output);
t.deepEqual(result.warnings().length, 0);
});
}
test('converts icon name into unicode', t => {
return run(t, 'a{ font-awesome: camera }', 'a{ font-family: FontAwesome; content: \'\\f030\' }');
});
test('converts icon name into unicode with comma seperated selectors', t => {
return run(t, 'a, b{ font-awesome: camera }', 'a, b{ font-family: FontAwesome; content: \'\\f030\' }');
});
test('options', t => {
return run(
t,
'a{ font-awesome: camera }',
'a{ -moz-osx-font-smoothing: grayscale; -webkit-font-smoothing: antialiased; text-rendering: auto; font-size: inherit; font: normal normal normal FontAwesome; display: inline-block }\na::before{ content: \'\\f030\' }', { // eslint-disable-line max-len
replacement: true
}
);
});
test('options with comma seperated selectors', t => {
return run(
t,
'a, b{ font-awesome: camera }',
'a, b{ -moz-osx-font-smoothing: grayscale; -webkit-font-smoothing: antialiased; text-rendering: auto; font-size: inherit; font: normal normal normal FontAwesome; display: inline-block }\na::before, b::before{ content: \'\\f030\' }', { // eslint-disable-line max-len
replacement: true
}
);
});
test('if icon name doesn\'t exist just use the input value', t => {
return run(t, 'a{ font-awesome: doesnt-exist }', 'a{ content: doesnt-exist }');
});
test('extending the content, replacing inline fa- tags after', t => {
return run(t,
'a::before{ content: \'Test fa-camera\'}',
'a::before{ font-family: FontAwesome; content: \'Test \\f030\'}'
);
});
test('extending the content, replacing inline fa- tags before', t => {
return run(t,
'a::before{ content: \'fa-camera Test\'}',
'a::before{ font-family: FontAwesome; content: \'\\f030 Test\'}'
);
});
test('extending the content, replacing inline fa- tags middle', t => {
return run(t,
'a::before{ content: \'Test fa-camera Test\'}',
'a::before{ font-family: FontAwesome; content: \'Test \\f030 Test\'}'
);
});
test('extending the content, replacing inline fa- tags with a hyphen', t => {
return run(t,
'a::before{ content: \'Test fa-level-down Test\'}',
'a::before{ font-family: FontAwesome; content: \'Test \\f149 Test\'}'
);
});