Skip to content

Commit

Permalink
test: merge vitejs#6044
Browse files Browse the repository at this point in the history
  • Loading branch information
poyoho committed Jan 6, 2022
2 parents 0ea1d1a + 223148d commit 9492951
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/playground/css/__tests__/css.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,16 @@ test('async css modules', async () => {
expect(await getColor(red)).toBe('red')
expect(await getColor(green)).toBe('green')
expect(await getColor(blue2)).toBe('blue')
expect(await getColor(blue)).toBe('blue')
expect(await getColor(red)).toBe('red')
})

test('async css modules with normal css', async () => {
const black = await page.$('.async-modules-and-css-black')
const blue = await page.$('.async-modules-and-css-blue')

expect(await getColor(black)).toBe('black')
expect(await getColor(blue)).toBe('blue')
})

test('PostCSS dir-dependency', async () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/playground/css/async-modules-and-css/base.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.base {
font-size: 1rem;
color: hotpink;
}
9 changes: 9 additions & 0 deletions packages/playground/css/async-modules-and-css/black.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import './base.css'
import styles from './black.module.css'

const div = document.createElement('div')
div.className = `base ${styles.black} async-modules-and-css-black`
document.body.appendChild(div)
div.textContent = `async css modules and normal css (black) ${
getComputedStyle(div).color
}`
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.black {
color: black;
}
9 changes: 9 additions & 0 deletions packages/playground/css/async-modules-and-css/blue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import './base.css'
import styles from './blue.module.css'

const div = document.createElement('div')
div.className = `base ${styles.blue} async-modules-and-css-blue`
document.body.appendChild(div)
div.textContent = `async css modules and normal css (blue) ${
getComputedStyle(div).color
}`
3 changes: 3 additions & 0 deletions packages/playground/css/async-modules-and-css/blue.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.blue {
color: blue;
}
4 changes: 4 additions & 0 deletions packages/playground/css/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,7 @@ text('.inlined-code', inlined)
import('./async-modules/blue')
import('./async-modules/red')
import('./async-modules/green')

// async css module with normal css
import('./async-modules-and-css/black')
import('./async-modules-and-css/blue')

0 comments on commit 9492951

Please sign in to comment.