Skip to content

Commit 0de9daf

Browse files
committed
Added tests for CSS Level 4 range type media query
1 parent 1cf9ebd commit 0de9daf

5 files changed

+69
-44
lines changed

index.test.js

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,74 +31,55 @@ async function mediaMinmaxAfterNestedRun (input, output, opts) {
3131
expect(result.warnings()).toHaveLength(0)
3232
}
3333

34-
it('simple #1. mobile-first', async () => {
34+
it('[mf] simple #1', async () => {
3535
let input = fs.readFileSync('./test/s1-mobile.in.css', 'utf8')
3636
let output = fs.readFileSync('./test/s1-mobile.out.css', 'utf8')
3737
await run(input, output, { sort: 'mobile-first' })
3838
})
3939

40-
it('simple #1. desktop-first', async () => {
40+
it('[df] simple #1', async () => {
4141
let input = fs.readFileSync('./test/s1-desktop.in.css', 'utf8')
4242
let output = fs.readFileSync('./test/s1-desktop.out.css', 'utf8')
4343
await run(input, output, { sort: 'desktop-first' })
4444
})
4545

46-
it('simple #2. mobile-first', async () => {
46+
it('[mf] simple #2', async () => {
4747
let input = fs.readFileSync('./test/s2-mobile.in.css', 'utf8')
4848
let output = fs.readFileSync('./test/s2-mobile.out.css', 'utf8')
4949
await run(input, output, { sort: 'mobile-first' })
5050
})
5151

52-
it('simple #2. desktop-first', async () => {
52+
it('[df] simple #2', async () => {
5353
let input = fs.readFileSync('./test/s2-desktop.in.css', 'utf8')
5454
let output = fs.readFileSync('./test/s2-desktop.out.css', 'utf8')
5555
await run(input, output, { sort: 'desktop-first' })
5656
})
5757

58-
it('without dimension #1. mobile-first', async () => {
58+
it('[mf] without dimension #1', async () => {
5959
let input = fs.readFileSync('./test/wd1-mobile.in.css', 'utf8')
6060
let output = fs.readFileSync('./test/wd1-mobile.out.css', 'utf8')
6161
await run(input, output, { sort: 'mobile-first' })
6262
})
6363

64-
it('without dimension #1. desktop-first', async () => {
64+
it('[df] without dimension #1', async () => {
6565
let input = fs.readFileSync('./test/wd1-desktop.in.css', 'utf8')
6666
let output = fs.readFileSync('./test/wd1-desktop.out.css', 'utf8')
6767
await run(input, output, { sort: 'desktop-first' })
6868
})
6969

70-
it('mixed #1. mobile-first', async () => {
70+
it('[mf] mixed #1', async () => {
7171
let input = fs.readFileSync('./test/mixed-mobile.in.css', 'utf8')
7272
let output = fs.readFileSync('./test/mixed-mobile.out.css', 'utf8')
7373
await run(input, output, { sort: 'mobile-first' })
7474
})
7575

76-
it('mixed #1. desktop-first', async () => {
76+
it('[df] mixed #1', async () => {
7777
let input = fs.readFileSync('./test/mixed-desktop.in.css', 'utf8')
7878
let output = fs.readFileSync('./test/mixed-desktop.out.css', 'utf8')
7979
await run(input, output, { sort: 'desktop-first' })
8080
})
8181

82-
it('postcss nested', async () => {
83-
let input = fs.readFileSync('./test/postcss.nested.in.css', 'utf8')
84-
let output = fs.readFileSync('./test/postcss.nested.out.css', 'utf8')
85-
await nestedRun(input, output)
86-
})
87-
88-
it('postcss media minmax -> nested', async () => {
89-
let input = fs.readFileSync('./test/postcss.media.minmax.in.css', 'utf8')
90-
let output = fs.readFileSync('./test/postcss.media.minmax.out.css', 'utf8')
91-
await mediaMinmaxBeforeNestedRun(input, output)
92-
})
93-
94-
it('postcss nested -> media minmax', async () => {
95-
let input = fs.readFileSync('./test/postcss.media.minmax.in.css', 'utf8')
96-
let output = fs.readFileSync('./test/postcss.media.minmax.out.css', 'utf8')
97-
await mediaMinmaxAfterNestedRun(input, output)
98-
})
99-
100-
101-
it('configuration(mixed #1): [mobile first] unitlessMqAlwaysFirst: FALSE', async () => {
82+
it('[mf] configuration(mixed #1): unitlessMqAlwaysFirst: FALSE', async () => {
10283
let input = fs.readFileSync('./test/configuration/false-mixed-mobile.in.css', 'utf8')
10384
let output = fs.readFileSync('./test/configuration/false-mixed-mobile.out.css', 'utf8')
10485

@@ -110,8 +91,7 @@ it('configuration(mixed #1): [mobile first] unitlessMqAlwaysFirst: FALSE', async
11091
await run(input, output, options)
11192
})
11293

113-
114-
it('configuration(mixed #1): [mobile first] unitlessMqAlwaysFirst: TRUE', async () => {
94+
it('[mf] configuration(mixed #1): unitlessMqAlwaysFirst: TRUE', async () => {
11595
let input = fs.readFileSync('./test/configuration/true-mixed-mobile.in.css', 'utf8')
11696
let output = fs.readFileSync('./test/configuration/true-mixed-mobile.out.css', 'utf8')
11797

@@ -123,8 +103,7 @@ it('configuration(mixed #1): [mobile first] unitlessMqAlwaysFirst: TRUE', async
123103
await run(input, output, options)
124104
})
125105

126-
127-
it('configuration(mixed #2): [desktop first] unitlessMqAlwaysFirst: FALSE', async () => {
106+
it('[df] configuration(mixed #2): unitlessMqAlwaysFirst: FALSE', async () => {
128107
let input = fs.readFileSync('./test/configuration/false-mixed-desktop.in.css', 'utf8')
129108
let output = fs.readFileSync('./test/configuration/false-mixed-desktop.out.css', 'utf8')
130109

@@ -137,8 +116,7 @@ it('configuration(mixed #2): [desktop first] unitlessMqAlwaysFirst: FALSE', asyn
137116
await run(input, output, options)
138117
})
139118

140-
141-
it('configuration(mixed #2): [desktop first] unitlessMqAlwaysFirst: TRUE', async () => {
119+
it('[df] configuration(mixed #2): unitlessMqAlwaysFirst: TRUE', async () => {
142120
let input = fs.readFileSync('./test/configuration/true-mixed-desktop.in.css', 'utf8')
143121
let output = fs.readFileSync('./test/configuration/true-mixed-desktop.out.css', 'utf8')
144122

@@ -150,3 +128,21 @@ it('configuration(mixed #2): [desktop first] unitlessMqAlwaysFirst: TRUE', async
150128
}
151129
await run(input, output, options)
152130
})
131+
132+
it('postcss nested', async () => {
133+
let input = fs.readFileSync('./test/postcss.nested.in.css', 'utf8')
134+
let output = fs.readFileSync('./test/postcss.nested.out.css', 'utf8')
135+
await nestedRun(input, output)
136+
})
137+
138+
it('postcss media minmax -> nested', async () => {
139+
let input = fs.readFileSync('./test/postcss.media.minmax.in.css', 'utf8')
140+
let output = fs.readFileSync('./test/postcss.media.minmax.out.css', 'utf8')
141+
await mediaMinmaxBeforeNestedRun(input, output)
142+
})
143+
144+
it('postcss nested -> media minmax', async () => {
145+
let input = fs.readFileSync('./test/postcss.media.minmax.in.css', 'utf8')
146+
let output = fs.readFileSync('./test/postcss.media.minmax.out.css', 'utf8')
147+
await mediaMinmaxAfterNestedRun(input, output)
148+
})

test/mixed-desktop.in.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
@media screen and (max-width: 1280px) {
2626
.md { color: #000 }
2727
}
28+
@media screen and (width <= 1200px) {
29+
.md {
30+
color: #000
31+
}
32+
}
2833
@media print and (orientation: portrait) {
2934
.md { color: #000 }
3035
}

test/mixed-desktop.out.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
@media screen and (max-width: 1280px) {
22
.md { color: #000 } }
3+
@media screen and (width <= 1200px) {
4+
.md {
5+
color: #000
6+
} }
37
@media screen and (max-width: 640px) {
48
.md { color: #000 } }
59
@media screen and (min-width: 768px) {

test/mixed-mobile.in.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
@media screen and (max-width: 640px) {
1111
.mm { color: #fff }
1212
}
13+
@media screen and (width > 640px) {
14+
.mm {
15+
color: #fff
16+
}
17+
}
1318
@media screen and (orientation: landscape) {
1419
.mm { color: #fff }
1520
}

test/mixed-mobile.out.css

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
1+
@media screen and (width > 640px) {
2+
.mm {
3+
color: #fff
4+
}
5+
}
16
@media screen and (min-width: 768px) {
2-
.mm { color: #fff } }
7+
.mm { color: #fff }
8+
}
39
@media screen and (min-width: 1280px) {
4-
.mm { color: #fff } }
10+
.mm { color: #fff }
11+
}
512
@media screen and (max-width: 1280px) {
6-
.mm { color: #fff } }
13+
.mm { color: #fff }
14+
}
715
@media screen and (max-width: 640px) {
8-
.mm { color: #fff } }
16+
.mm { color: #fff }
17+
}
918
@media screen and (orientation: landscape) {
10-
.mm { color: #fff } }
19+
.mm { color: #fff }
20+
}
1121
@media screen and (orientation: portrait) {
12-
.mm { color: #fff } }
22+
.mm { color: #fff }
23+
}
1324
@media tv {
14-
.mm { color: #fff } }
25+
.mm { color: #fff }
26+
}
1527
@media print {
16-
.mm { color: #fff } }
28+
.mm { color: #fff }
29+
}
1730
@media print and (orientation: landscape) {
18-
.mm { color: #fff } }
31+
.mm { color: #fff }
32+
}
1933
@media print and (orientation: portrait) {
20-
.mm { color: #fff } }
34+
.mm { color: #fff }
35+
}

0 commit comments

Comments
 (0)