Skip to content

Commit

Permalink
test: Add test for mixed css and css modules
Browse files Browse the repository at this point in the history
  • Loading branch information
IanVS committed Jan 6, 2022
1 parent e6cd509 commit 223148d
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/playground/css/__tests__/css.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,14 @@ test('async css modules', async () => {
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 () => {
const el1 = await page.$('.dir-dep')
const el2 = await page.$('.dir-dep-2')
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 @@ -72,3 +72,7 @@ text('.inlined-code', inlined)
// async css modules
import('./async-modules/blue')
import('./async-modules/red')

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

0 comments on commit 223148d

Please sign in to comment.