Skip to content

Commit

Permalink
feat: add test case and remove react
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyuan0704 committed Sep 14, 2022
1 parent 4df9062 commit 85ed65d
Show file tree
Hide file tree
Showing 20 changed files with 51 additions and 79 deletions.

This file was deleted.

7 changes: 0 additions & 7 deletions playground/async-chunk-css-order/components/BlueButton.jsx

This file was deleted.

10 changes: 0 additions & 10 deletions playground/async-chunk-css-order/components/Button.jsx

This file was deleted.

7 changes: 0 additions & 7 deletions playground/async-chunk-css-order/components/GreenButton.jsx

This file was deleted.

15 changes: 0 additions & 15 deletions playground/async-chunk-css-order/index.html

This file was deleted.

10 changes: 0 additions & 10 deletions playground/async-chunk-css-order/main.jsx

This file was deleted.

15 changes: 0 additions & 15 deletions playground/async-chunk-css-order/package.json

This file was deleted.

1 change: 0 additions & 1 deletion playground/async-chunk-css-order/vite.config.js

This file was deleted.

17 changes: 16 additions & 1 deletion playground/css/__tests__/css.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
page,
removeFile,
serverLogs,
untilUpdated
untilUpdated,
withRetry
} from '~utils'

// note: tests should retrieve the element at the beginning of test and reuse it
Expand Down Expand Up @@ -455,3 +456,17 @@ test.runIf(isBuild)('warning can be suppressed by esbuild.logOverride', () => {
expect(log).not.toMatch('unsupported-css-property')
})
})

// NOTE: the match inline snapshot should generate by build mode
test('async css order', async () => {
await withRetry(async () => {
expect(await getColor('.async-green')).toMatchInlineSnapshot('"green"')
expect(await getColor('.async-blue')).toMatchInlineSnapshot('"blue"')
}, true)
})

test('async css order with css modules', async () => {
await withRetry(async () => {
expect(await getColor('.modules-pink')).toMatchInlineSnapshot('"pink"')
}, true)
})
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.blue {
.async-blue {
color: blue;
}
4 changes: 4 additions & 0 deletions playground/css/async/async-1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { createButton } from './base'
import './async-1.css'

createButton('async-blue')
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.green {
.async-green {
color: green;
}
4 changes: 4 additions & 0 deletions playground/css/async/async-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { createButton } from './base'
import './async-2.css'

createButton('async-green')
4 changes: 4 additions & 0 deletions playground/css/async/async-3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { createButton } from './base'
import styles from './async-3.module.css'

createButton(`${styles['async-pink']} modules-pink`)
3 changes: 3 additions & 0 deletions playground/css/async/async-3.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.async-pink {
color: pink;
}
File renamed without changes.
8 changes: 8 additions & 0 deletions playground/css/async/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import './base.css'

export function createButton(className) {
const button = document.createElement('button')
button.className = `btn ${className}`
document.body.appendChild(button)
button.textContent = `button ${getComputedStyle(button).color}`
}
3 changes: 3 additions & 0 deletions playground/css/async/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import('./async-1.js')
import('./async-2.js')
import('./async-3.js')
5 changes: 5 additions & 0 deletions playground/css/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ <h1>CSS</h1>
<pre class="imported-css"></pre>
<pre class="imported-css-glob"></pre>
<pre class="imported-css-globEager"></pre>
<div>
<p>import.meta.glob import css</p>
<span class="dir-import">dir-import</span>
<span class="dir-import-2">dir-import-2</span>
</div>

<p class="postcss">
<span class="nesting">PostCSS nesting plugin: this should be pink</span>
Expand Down
2 changes: 2 additions & 0 deletions playground/css/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,5 @@ document
.classList.add(aliasModule.aliasedModule)

import './unsupported.css'

import './async/index'

0 comments on commit 85ed65d

Please sign in to comment.