Skip to content

Commit 55bb3bf

Browse files
committed
add test to ensure consistent order in screens output
1 parent 9c94a14 commit 55bb3bf

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tests/tailwind-screens.test.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,51 @@ test('`@tailwind screens` works as an alias for `@tailwind variants`', async ()
6565
`)
6666
})
6767
})
68+
69+
test('screen names are in the correct order', () => {
70+
// Using custom css function here, because otherwise with String.raw, we run
71+
// into an issue with `\31 ` escapes. If we use `\31 ` then JS complains
72+
// about strict mode. But `\\31 ` is not what it expected.
73+
function css(templates) {
74+
return templates.join('')
75+
}
76+
77+
let config = {
78+
content: [
79+
{
80+
raw: html`<div
81+
class="768:font-light 1200:font-normal 1800:font-bold max-w-768 container"
82+
></div>`,
83+
},
84+
],
85+
theme: {
86+
screens: [
87+
[1800, { max: '1800px' }],
88+
[1200, { max: '1200px' }],
89+
[768, { max: '768px' }],
90+
],
91+
},
92+
}
93+
94+
return run('@tailwind utilities;', config).then((result) => {
95+
return expect(result.css).toMatchFormattedCss(css`
96+
@media (max-width: 1800px) {
97+
.\\31 800\\:font-bold {
98+
font-weight: 700;
99+
}
100+
}
101+
102+
@media (max-width: 1200px) {
103+
.\\31 200\\:font-normal {
104+
font-weight: 400;
105+
}
106+
}
107+
108+
@media (max-width: 768px) {
109+
.\\37 68\\:font-light {
110+
font-weight: 300;
111+
}
112+
}
113+
`)
114+
})
115+
})

0 commit comments

Comments
 (0)