-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
49 lines (43 loc) · 1.35 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
let postcss = require('postcss')
let plugin = require('./')
function run (input, output, options) {
return postcss([plugin(options)]).process(input, { from: undefined })
.then(result => {
expect(result.css.replace(/\s+/g, ' ')).toEqual(output)
expect(result.warnings()).toHaveLength(0)
})
}
it('add new font-display', () => {
return run(
'@font-face { font-family: \'My Font\'; }',
'@font-face { font-family: \'My Font\'; font-display: swap; }',
{ display: 'swap' }
)
})
it('pass exists font-display', () => {
return run(
'@font-face { font-family: \'My Font\'; font-display: auto; }',
'@font-face { font-family: \'My Font\'; font-display: auto; }',
{ display: 'swap', replace: false }
)
})
it('replace exists font-display', () => {
return run(
'@font-face { font-family: \'My Font\'; font-display: auto; }',
'@font-face { font-family: \'My Font\'; font-display: swap; }',
{ display: 'swap', replace: true }
)
})
it('multiple options', () => {
return run(
[
'@font-face { font-family: \'FontAwesome\'; }',
'@font-face { font-family: \'My Font\'; }'
].join(''),
[
'@font-face { font-family: \'FontAwesome\'; font-display: block; }',
'@font-face { font-family: \'My Font\'; font-display: swap; }'
].join(''),
[{ test: 'FontAwesome', display: 'block' }]
)
})