-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
59 lines (51 loc) · 1.65 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
const postcss = require('postcss')
const plugin = require('./')
async function run(input, output, opts) {
const result = await postcss([plugin(opts)]).process(input, { from: undefined })
expect(result.css).toEqual(output)
expect(result.warnings()).toHaveLength(0)
}
it('background', async () => {
await run(
'a { background: #000 url(./test.png) no-repeat; }',
'a { background: #000 url(./test.png) no-repeat; }\n.webp a { background-image: url(./test.png?x-oss-process=image/format,webp); }',
{}
)
})
it('background-image', async () => {
await run(
'a { background-image: url(./test.png); }',
'a { background-image: url(./test.png); }\n.webp a { background-image: url(./test.png?x-oss-process=image/format,webp); }',
{}
)
})
it('prefix', async () => {
await run(
'a { background-image: url(./test.png); }',
'a { background-image: url(./test.png); }\n.webp a { background-image: url(./test.png?x-oss-process=test); }',
{ prefix: 'x-oss-process=test' }
)
})
it('pattern', async () => {
await run('a { background-image: url(./test.png); }', 'a { background-image: url(./test.png); }', {
pattern: /\.gif/
})
})
it('cssModules', async () => {
await run(
'a { background-image: url(./test.png); }',
'a { background-image: url(./test.png); }\n:global(.webp) a { background-image: url(./test.png?x-oss-process=image/format,webp); }',
{
cssModules: true
}
)
})
it('ignoreComment', async () => {
await run(
'a { background-image: url(./test.png); /* webp-disable */ }',
'a { background-image: url(./test.png); /* webp-disable */ }',
{
ignoreComment: 'webp-disable'
}
)
})