This repository has been archived by the owner on Jun 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.js
50 lines (43 loc) · 2.14 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
var postcss = require('postcss')
var plugin = require('./')
function run (input, output, opts) {
return postcss([plugin(opts)]).process(input).then(function (result) {
expect(result.css).toEqual(output)
expect(result.warnings()).toHaveLength(0)
})
}
it('renders no-query fallback with default prefix and one media query expression in array', function () {
return run(
'@media (min-width: 600px) { .foo { border: 1px solid red; } } @media (min-width: 1024px) { .foo { border: 1px solid yellow; } }',
'@media (min-width: 600px) { .foo { border: 1px solid red; } } @media (min-width: 1024px) { .foo { border: 1px solid yellow; } } .no-query .foo { border: 1px solid yellow; }',
{ query: ['(min-width: 1024px)'] }
)
})
it('renders no-query fallback with default prefix and multiple media query expressions in array', function () {
return run(
'@media (min-width: 600px) { .foo { border: 1px solid red; } } @media (min-width: 1024px) { .foo { border: 1px solid yellow; } }',
'@media (min-width: 600px) { .foo { border: 1px solid red; } } .no-query .foo { border: 1px solid red; } @media (min-width: 1024px) { .foo { border: 1px solid yellow; } } .no-query .foo { border: 1px solid yellow; }',
{ query: ['(min-width: 600px)', '(min-width: 1024px)'] }
)
})
it('renders no-query fallback with custom prefix', function () {
return run(
'@media (min-width: 1024px) { .foo { border: 1px solid yellow; } }',
'@media (min-width: 1024px) { .foo { border: 1px solid yellow; } } .nobp .foo { border: 1px solid yellow; }',
{ prefix: '.nobp', query: ['(min-width: 1024px)'] }
)
})
it('renders no no-query fallback if fallback is deactivated', function () {
return run(
'@media (min-width: 1024px) { .foo { border: 1px solid yellow; } }',
'@media (min-width: 1024px) { .foo { border: 1px solid yellow; } }',
{ fallback: false, query: ['(min-width: 1024px)'] }
)
})
it('renders no no-query fallback if query array is empty', function () {
return run(
'@media (min-width: 1024px) { .foo { border: 1px solid yellow; } }',
'@media (min-width: 1024px) { .foo { border: 1px solid yellow; } }',
{ query: [] }
)
})