Skip to content

Commit 5f2c76a

Browse files
committed
test: add #8461 test case
1 parent 4ed9182 commit 5f2c76a

File tree

9 files changed

+50
-1
lines changed

9 files changed

+50
-1
lines changed

playground/css/__tests__/css.spec.ts

+5
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,11 @@ test('PostCSS dir-dependency', async () => {
349349
}
350350
})
351351

352+
test('import dependency includes css import', async () => {
353+
expect(await getColor('.css-js-dep')).toBe('green')
354+
expect(await getColor('.css-js-dep-module')).toBe('green')
355+
})
356+
352357
test('URL separation', async () => {
353358
const urlSeparated = await page.$('.url-separated')
354359
const baseUrl = 'url(images/dog.webp)'
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.cssJsDepModule {
2+
color: green;
3+
}

playground/css/css-js-dep/foo.css

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.css-js-dep {
2+
color: green;
3+
}

playground/css/css-js-dep/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import './foo.css'
2+
import barModuleClasses from './bar.module.css'
3+
4+
export { barModuleClasses }
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "css-js-dep",
3+
"private": true,
4+
"type": "module",
5+
"version": "1.0.0",
6+
"main": "index.js"
7+
}

playground/css/index.html

+7
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ <h1>CSS</h1>
117117
PostCSS dir-dependency (file 3): this should be grey too
118118
</p>
119119

120+
<p class="css-js-dep">
121+
import dependency includes 'import "./foo.css"': this should be green
122+
</p>
123+
<p class="css-js-dep-module">
124+
import dependency includes 'import "./bar.module.css"': this should be green
125+
</p>
126+
120127
<p class="url-separated">
121128
URL separation preservation: should have valid background-image
122129
</p>

playground/css/main.js

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ text('.charset-css', charset)
4747
import './dep.css'
4848
import './glob-dep.css'
4949

50+
import { barModuleClasses } from 'css-js-dep'
51+
document
52+
.querySelector('.css-js-dep-module')
53+
.classList.add(barModuleClasses.cssJsDepModule)
54+
5055
function text(el, text) {
5156
document.querySelector(el).textContent = text
5257
}

playground/css/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"devDependencies": {
1515
"css-dep": "link:./css-dep",
16+
"css-js-dep": "file:./css-js-dep",
1617
"fast-glob": "^3.2.11",
1718
"less": "^4.1.3",
1819
"postcss-nested": "^5.0.6",

pnpm-lock.yaml

+15-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)