Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improvements
  • Loading branch information
philipp-spiess authored and adamwathan committed Nov 7, 2024
commit fa25b2128652e3526f427f7315a7df4cf949bf61
25 changes: 22 additions & 3 deletions integrations/vite/other-transforms.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import dedent from 'dedent'
import { describe, expect } from 'vitest'
import { css, fetchStyles, html, retryAssertion, test, ts, txt } from '../utils'

Expand Down Expand Up @@ -30,7 +31,7 @@ function createSetup(transformer: 'postcss' | 'lightningcss') {
name: 'recolor',
transform(code, id) {
if (id.includes('.css')) {
return code.replace(/red/g, 'blue')
return code.replace(/red;/g, 'blue;')
}
},
},
Expand All @@ -42,7 +43,7 @@ function createSetup(transformer: 'postcss' | 'lightningcss') {
<link rel="stylesheet" href="./src/index.css" />
</head>
<body>
<div class="foo">Hello, world!</div>
<div class="foo [background-color:red]">Hello, world!</div>
</body>
`,
'src/index.css': css`
Expand All @@ -59,7 +60,7 @@ function createSetup(transformer: 'postcss' | 'lightningcss') {

for (let transformer of ['postcss', 'lightningcss'] as const) {
describe(transformer, () => {
test(`production build`, createSetup(transformer), async ({ fs, exec }) => {
test.only(`production build`, createSetup(transformer), async ({ fs, exec }) => {
await exec('pnpm vite build')

let files = await fs.glob('dist/**/*.css')
Expand All @@ -72,6 +73,12 @@ for (let transformer of ['postcss', 'lightningcss'] as const) {
color: blue;
}
`,
// Running the transforms on utilities generated by Tailwind might change in the future
dedent`
.\[background-color\:red\] {
background-color: blue;
}
`,
])
})

Expand All @@ -86,6 +93,12 @@ for (let transformer of ['postcss', 'lightningcss'] as const) {
color: blue;
}
`)
// Running the transforms on utilities generated by Tailwind might change in the future
expect(styles).toContain(dedent`
.\[background-color\:red\] {
background-color: blue;
}
`)
})

await retryAssertion(async () => {
Expand Down Expand Up @@ -123,6 +136,12 @@ for (let transformer of ['postcss', 'lightningcss'] as const) {
color: blue;
}
`)
// Running the transforms on utilities generated by Tailwind might change in the future
expect(styles).toContain(dedent`
.\[background-color\:red\] {
background-color: blue;
}
`)
})

await retryAssertion(async () => {
Expand Down
3 changes: 1 addition & 2 deletions integrations/vite/vue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ test(
expect(files).toHaveLength(1)

await fs.expectFileToContain(files[0][0], [candidate`underline`, candidate`foo`])

await fs.expectFileNotToContain(files[0][0], [':deep(.bar)'])
await fs.expectFileToContain(files[0][0], ['.bar{'])
},
)