Skip to content

Commit 4bdcc62

Browse files
authored
Merge branch 'canary' into update/updating-query
2 parents c5e36fc + c4cf641 commit 4bdcc62

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { foo } from './index.module.css'
2+
3+
export default function Home() {
4+
return <div id="verify-div" className={foo} />
5+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.foo {
2+
position: relative;
3+
}
4+
5+
.foo :global(.bar),
6+
.foo :global(.baz) {
7+
height: 100%;
8+
overflow: hidden;
9+
}
10+
11+
.foo :global(.lol) {
12+
width: 80%;
13+
}
14+
15+
.foo > :global(.lel) {
16+
width: 80%;
17+
}

test/integration/css-modules/test/index.test.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,53 @@ describe('Basic CSS Module Support', () => {
6565
})
6666
})
6767

68+
describe('3rd Party CSS Module Support', () => {
69+
const appDir = join(fixturesDir, '3rd-party-module')
70+
71+
let appPort
72+
let app
73+
beforeAll(async () => {
74+
await remove(join(appDir, '.next'))
75+
await nextBuild(appDir)
76+
appPort = await findPort()
77+
app = await nextStart(appDir, appPort)
78+
})
79+
afterAll(async () => {
80+
await killApp(app)
81+
})
82+
83+
it(`should've emitted a single CSS file`, async () => {
84+
const cssFolder = join(appDir, '.next/static/css')
85+
86+
const files = await readdir(cssFolder)
87+
const cssFiles = files.filter(f => /\.css$/.test(f))
88+
89+
expect(cssFiles.length).toBe(1)
90+
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
91+
92+
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatchInlineSnapshot(
93+
`".index_foo__29BAH{position:relative}.index_foo__29BAH .bar,.index_foo__29BAH .baz{height:100%;overflow:hidden}.index_foo__29BAH .lol,.index_foo__29BAH>.lel{width:80%}"`
94+
)
95+
})
96+
97+
it(`should've injected the CSS on server render`, async () => {
98+
const content = await renderViaHTTP(appPort, '/')
99+
const $ = cheerio.load(content)
100+
101+
const cssPreload = $('link[rel="preload"][as="style"]')
102+
expect(cssPreload.length).toBe(1)
103+
expect(cssPreload.attr('href')).toMatch(/^\/_next\/static\/css\/.*\.css$/)
104+
105+
const cssSheet = $('link[rel="stylesheet"]')
106+
expect(cssSheet.length).toBe(1)
107+
expect(cssSheet.attr('href')).toMatch(/^\/_next\/static\/css\/.*\.css$/)
108+
109+
expect($('#verify-div').attr('class')).toMatchInlineSnapshot(
110+
`"index_foo__29BAH"`
111+
)
112+
})
113+
})
114+
68115
describe('Has CSS Module in computed styles in Development', () => {
69116
const appDir = join(fixturesDir, 'dev-module')
70117

0 commit comments

Comments
 (0)