Skip to content

Commit 2674e65

Browse files
authored
Merge pull request #619 from tailwindcss/prove-613-issue
Add failing tests for #613
2 parents ba86cb3 + e82ef53 commit 2674e65

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

__tests__/prefixTree.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,24 @@ test('it handles a function as the prefix', () => {
3737
expect(result.warnings().length).toBe(0)
3838
})
3939

40+
test('it properly prefixes selectors with non-standard characters', () => {
41+
const input = postcss.parse(`
42+
.hello\\:world { color: blue; }
43+
.foo\\/bar { color: green; }
44+
.wew\\.lad { color: red; }
45+
`)
46+
47+
const expected = `
48+
.tw-hello\\:world { color: blue; }
49+
.tw-foo\\/bar { color: green; }
50+
.tw-wew\\.lad { color: red; }
51+
`
52+
53+
const result = prefixTree(input, 'tw-').toResult()
54+
expect(result.css).toEqual(expected)
55+
expect(result.warnings().length).toBe(0)
56+
})
57+
4058
test('it prefixes all classes in a selector', () => {
4159
const input = postcss.parse(`
4260
.btn-blue .w-1\\/4 > h1.text-xl + a .bar { color: red; }

__tests__/responsiveAtRule.test.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,46 @@ test('it can generate responsive variants with a custom separator', () => {
8686
})
8787
})
8888

89+
test('it can generate responsive variants when classes have non-standard characters', () => {
90+
const input = `
91+
@responsive {
92+
.hover\\:banana { color: yellow; }
93+
.chocolate-2\\.5 { color: brown; }
94+
}
95+
`
96+
97+
const output = `
98+
.hover\\:banana { color: yellow; }
99+
.chocolate-2\\.5 { color: brown; }
100+
@media (min-width: 500px) {
101+
.sm\\:hover\\:banana { color: yellow; }
102+
.sm\\:chocolate-2\\.5 { color: brown; }
103+
}
104+
@media (min-width: 750px) {
105+
.md\\:hover\\:banana { color: yellow; }
106+
.md\\:chocolate-2\\.5 { color: brown; }
107+
}
108+
@media (min-width: 1000px) {
109+
.lg\\:hover\\:banana { color: yellow; }
110+
.lg\\:chocolate-2\\.5 { color: brown; }
111+
}
112+
`
113+
114+
return run(input, {
115+
screens: {
116+
sm: '500px',
117+
md: '750px',
118+
lg: '1000px',
119+
},
120+
options: {
121+
separator: ':',
122+
},
123+
}).then(result => {
124+
expect(result.css).toMatchCss(output)
125+
expect(result.warnings().length).toBe(0)
126+
})
127+
})
128+
89129
test('responsive variants are grouped', () => {
90130
const input = `
91131
@responsive {

0 commit comments

Comments
 (0)