Skip to content

Commit

Permalink
test: feat more test
Browse files Browse the repository at this point in the history
  • Loading branch information
poyoho committed Jan 4, 2022
1 parent 4e10f6f commit 350ae16
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/playground/css/__tests__/css.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,13 @@ test('treeshaken async chunk', async () => {
test('async css modules', async () => {
const blue = await page.$('.async-modules-blue')
const red = await page.$('.async-modules-red')
const green = await page.$('.async-modules-green')
const blue2 = await page.$('.async-modules-blue2')

expect(await getColor(blue)).toBe('blue')
expect(await getColor(red)).toBe('red')
expect(await getColor(green)).toBe('green')
expect(await getColor(blue2)).toBe('blue')
})

test('PostCSS dir-dependency', async () => {
Expand Down
10 changes: 10 additions & 0 deletions packages/playground/css/async-modules/base2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import styles from './red.module.css'

export function baseAsync(className, color) {
const div = document.createElement('div')
div.className = `${styles.red} ${className} async-modules-${color}`
document.body.appendChild(div)
div.textContent = `async css modules (${color}) ${
getComputedStyle(div).color
}`
}
6 changes: 6 additions & 0 deletions packages/playground/css/async-modules/green.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { baseAsync } from './base2'
import green from './green.module.css'
import blue from './blue.module.css'

baseAsync(green.green, 'green')
baseAsync(blue.blue, 'blue2')
3 changes: 3 additions & 0 deletions packages/playground/css/async-modules/green.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.green {
color: green;
}
1 change: 1 addition & 0 deletions packages/playground/css/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ text('.inlined-code', inlined)
// async css modules
import('./async-modules/blue')
import('./async-modules/red')
import('./async-modules/green')

0 comments on commit 350ae16

Please sign in to comment.