Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
55e966bb
Unverified
Commit
55e966bb
authored
Dec 13, 2019
by
Joe Haddad
Committed by
GitHub
Dec 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test CSS Behavior (#9733)
* Test CSS Behavior * adjust files
parent
88de2328
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
83 additions
and
0 deletions
+83
-0
index.js
test/integration/css-fixtures/composes-basic/pages/index.js
+9
-0
index.module.css
...ration/css-fixtures/composes-basic/pages/index.module.css
+9
-0
index.js
...integration/css-fixtures/composes-external/pages/index.js
+9
-0
index.module.css
...ion/css-fixtures/composes-external/pages/index.module.css
+4
-0
other.css
...ntegration/css-fixtures/composes-external/pages/other.css
+4
-0
index.test.js
test/integration/css-modules/test/index.test.js
+48
-0
No files found.
test/integration/css-fixtures/composes-basic/pages/index.js
0 → 100644
View file @
55e966bb
import
{
subClass
}
from
'./index.module.css'
export
default
function
Home
()
{
return
(
<
div
id
=
"verify-yellow"
className
=
{
subClass
}
>
This
text
should
be
yellow
on
blue
.
<
/div
>
)
}
test/integration/css-fixtures/composes-basic/pages/index.module.css
0 → 100644
View file @
55e966bb
.className
{
background
:
red
;
color
:
yellow
;
}
.subClass
{
composes
:
className
;
background
:
blue
;
}
test/integration/css-fixtures/composes-external/pages/index.js
0 → 100644
View file @
55e966bb
import
{
subClass
}
from
'./index.module.css'
export
default
function
Home
()
{
return
(
<
div
id
=
"verify-yellow"
className
=
{
subClass
}
>
This
text
should
be
yellow
on
blue
.
<
/div
>
)
}
test/integration/css-fixtures/composes-external/pages/index.module.css
0 → 100644
View file @
55e966bb
.subClass
{
composes
:
className
from
'./other.css'
;
background
:
blue
;
}
test/integration/css-fixtures/composes-external/pages/other.css
0 → 100644
View file @
55e966bb
.className
{
background
:
red
;
color
:
yellow
;
}
test/integration/css-modules/test/index.test.js
View file @
55e966bb
...
...
@@ -223,3 +223,51 @@ describe('Valid CSS Module Usage from within node_modules', () => {
)
})
})
describe
(
'CSS Module Composes Usage (Basic)'
,
()
=>
{
// This is a very bad feature. Do not use it.
const
appDir
=
join
(
fixturesDir
,
'composes-basic'
)
beforeAll
(
async
()
=>
{
await
remove
(
join
(
appDir
,
'.next'
))
await
nextBuild
(
appDir
)
})
it
(
`should've emitted a single CSS file`
,
async
()
=>
{
const
cssFolder
=
join
(
appDir
,
'.next/static/css'
)
const
files
=
await
readdir
(
cssFolder
)
const
cssFiles
=
files
.
filter
(
f
=>
/
\.
css$/
.
test
(
f
))
expect
(
cssFiles
.
length
).
toBe
(
1
)
const
cssContent
=
await
readFile
(
join
(
cssFolder
,
cssFiles
[
0
]),
'utf8'
)
expect
(
cssContent
.
replace
(
/
\/\*
.*
?\*\/
/g
,
''
).
trim
()).
toMatchInlineSnapshot
(
`".index_className__3gr_q{background:red;color:#ff0}.index_subClass__FUvW6{background:#00f}"`
)
})
})
describe
(
'CSS Module Composes Usage (External)'
,
()
=>
{
// This is a very bad feature. Do not use it.
const
appDir
=
join
(
fixturesDir
,
'composes-external'
)
beforeAll
(
async
()
=>
{
await
remove
(
join
(
appDir
,
'.next'
))
await
nextBuild
(
appDir
)
})
it
(
`should've emitted a single CSS file`
,
async
()
=>
{
const
cssFolder
=
join
(
appDir
,
'.next/static/css'
)
const
files
=
await
readdir
(
cssFolder
)
const
cssFiles
=
files
.
filter
(
f
=>
/
\.
css$/
.
test
(
f
))
expect
(
cssFiles
.
length
).
toBe
(
1
)
const
cssContent
=
await
readFile
(
join
(
cssFolder
,
cssFiles
[
0
]),
'utf8'
)
expect
(
cssContent
.
replace
(
/
\/\*
.*
?\*\/
/g
,
''
).
trim
()).
toMatchInlineSnapshot
(
`".other_className__21NIP{background:red;color:#ff0}.index_subClass__FUvW6{background:#00f}"`
)
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment