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
2f5b3e0d
Commit
2f5b3e0d
authored
Dec 28, 2019
by
Joe Haddad
Committed by
Tim Neutkens
Dec 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test Nested CSS Imports (#9855)
parent
f1f464b3
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
138 additions
and
0 deletions
+138
-0
index.js
...s-fixtures/nm-module-nested/node_modules/example/index.js
+3
-0
index.mjs
...-fixtures/nm-module-nested/node_modules/example/index.mjs
+1
-0
index.module.css
...es/nm-module-nested/node_modules/example/index.module.css
+6
-0
other.css
...-fixtures/nm-module-nested/node_modules/example/other.css
+6
-0
other2.css
...fixtures/nm-module-nested/node_modules/example/other2.css
+3
-0
other3.css
...fixtures/nm-module-nested/node_modules/example/other3.css
+3
-0
package.json
...xtures/nm-module-nested/node_modules/example/package.json
+4
-0
index.js
.../integration/css-fixtures/nm-module-nested/pages/index.js
+12
-0
index.js
...-fixtures/npm-import-nested/node_modules/example/index.js
+3
-0
index.mjs
...fixtures/npm-import-nested/node_modules/example/index.mjs
+1
-0
other.css
...fixtures/npm-import-nested/node_modules/example/other.css
+3
-0
package.json
...tures/npm-import-nested/node_modules/example/package.json
+4
-0
test.css
...-fixtures/npm-import-nested/node_modules/example/test.css
+5
-0
_app.js
.../integration/css-fixtures/npm-import-nested/pages/_app.js
+12
-0
index.js
...integration/css-fixtures/npm-import-nested/pages/index.js
+3
-0
global.css
...egration/css-fixtures/npm-import-nested/styles/global.css
+1
-0
index.test.js
test/integration/css-modules/test/index.test.js
+43
-0
index.test.js
test/integration/css/test/index.test.js
+25
-0
No files found.
test/integration/css-fixtures/nm-module-nested/node_modules/example/index.js
0 → 100644
View file @
2f5b3e0d
const
message
=
'Why hello there'
module
.
exports
=
{
message
}
test/integration/css-fixtures/nm-module-nested/node_modules/example/index.mjs
0 → 100644
View file @
2f5b3e0d
export
const
message
=
'Why hello there'
test/integration/css-fixtures/nm-module-nested/node_modules/example/index.module.css
0 → 100644
View file @
2f5b3e0d
@import
'other2.css'
;
.subClass
{
composes
:
className
from
'./other.css'
;
background
:
blue
;
}
test/integration/css-fixtures/nm-module-nested/node_modules/example/other.css
0 → 100644
View file @
2f5b3e0d
@import
'other3.css'
;
.className
{
background
:
red
;
color
:
yellow
;
}
test/integration/css-fixtures/nm-module-nested/node_modules/example/other2.css
0 → 100644
View file @
2f5b3e0d
.other2
{
color
:
red
;
}
test/integration/css-fixtures/nm-module-nested/node_modules/example/other3.css
0 → 100644
View file @
2f5b3e0d
.other3
{
color
:
violet
;
}
test/integration/css-fixtures/nm-module-nested/node_modules/example/package.json
0 → 100644
View file @
2f5b3e0d
{
"name"
:
"example"
,
"main"
:
"index"
}
test/integration/css-fixtures/nm-module-nested/pages/index.js
0 → 100644
View file @
2f5b3e0d
import
*
as
data
from
'example'
import
*
as
classes
from
'example/index.module.css'
function
Home
()
{
return
(
<
div
id
=
"nm-div"
>
{
JSON
.
stringify
(
data
)}
{
JSON
.
stringify
(
classes
)}
<
/div
>
)
}
export
default
Home
test/integration/css-fixtures/npm-import-nested/node_modules/example/index.js
0 → 100644
View file @
2f5b3e0d
const
message
=
'Why hello there'
module
.
exports
=
{
message
}
test/integration/css-fixtures/npm-import-nested/node_modules/example/index.mjs
0 → 100644
View file @
2f5b3e0d
export
const
message
=
'Why hello there'
test/integration/css-fixtures/npm-import-nested/node_modules/example/other.css
0 → 100644
View file @
2f5b3e0d
.other
{
color
:
blue
;
}
test/integration/css-fixtures/npm-import-nested/node_modules/example/package.json
0 → 100644
View file @
2f5b3e0d
{
"name"
:
"example"
,
"main"
:
"index"
}
test/integration/css-fixtures/npm-import-nested/node_modules/example/test.css
0 → 100644
View file @
2f5b3e0d
@import
url('other.css')
;
.test
{
color
:
red
;
}
test/integration/css-fixtures/npm-import-nested/pages/_app.js
0 → 100644
View file @
2f5b3e0d
import
React
from
'react'
import
App
from
'next/app'
import
'../styles/global.css'
class
MyApp
extends
App
{
render
()
{
const
{
Component
,
pageProps
}
=
this
.
props
return
<
Component
{...
pageProps
}
/
>
}
}
export
default
MyApp
test/integration/css-fixtures/npm-import-nested/pages/index.js
0 → 100644
View file @
2f5b3e0d
export
default
function
Home
()
{
return
<
div
className
=
"red-text"
>
This
text
should
be
red
.
<
/div
>
}
test/integration/css-fixtures/npm-import-nested/styles/global.css
0 → 100644
View file @
2f5b3e0d
@import
'~example/test.css'
;
test/integration/css-modules/test/index.test.js
View file @
2f5b3e0d
...
@@ -245,6 +245,49 @@ describe('Valid CSS Module Usage from within node_modules', () => {
...
@@ -245,6 +245,49 @@ describe('Valid CSS Module Usage from within node_modules', () => {
})
})
})
})
describe
(
'Valid Nested CSS Module Usage from within node_modules'
,
()
=>
{
const
appDir
=
join
(
fixturesDir
,
'nm-module-nested'
)
beforeAll
(
async
()
=>
{
await
remove
(
join
(
appDir
,
'.next'
))
})
let
appPort
let
app
beforeAll
(
async
()
=>
{
await
nextBuild
(
appDir
)
appPort
=
await
findPort
()
app
=
await
nextStart
(
appDir
,
appPort
)
})
afterAll
(
async
()
=>
{
await
killApp
(
app
)
})
it
(
`should've prerendered with relevant data`
,
async
()
=>
{
const
content
=
await
renderViaHTTP
(
appPort
,
'/'
)
const
$
=
cheerio
.
load
(
content
)
const
cssPreload
=
$
(
'#nm-div'
)
expect
(
cssPreload
.
text
()).
toMatchInlineSnapshot
(
`"{\\"message\\":\\"Why hello there\\"} {\\"subClass\\":\\"example_subClass__2YUgj other_className__bt_-E\\"}"`
)
})
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
(
`".other3_other3__1f9h7{color:violet}.other_className__bt_-E{background:red;color:#ff0}.other2_other2__2PUfY{color:red}.example_subClass__2YUgj{background:#00f}"`
)
})
})
describe
(
'CSS Module Composes Usage (Basic)'
,
()
=>
{
describe
(
'CSS Module Composes Usage (Basic)'
,
()
=>
{
// This is a very bad feature. Do not use it.
// This is a very bad feature. Do not use it.
const
appDir
=
join
(
fixturesDir
,
'composes-basic'
)
const
appDir
=
join
(
fixturesDir
,
'composes-basic'
)
...
...
test/integration/css/test/index.test.js
View file @
2f5b3e0d
...
@@ -537,6 +537,31 @@ describe('CSS Support', () => {
...
@@ -537,6 +537,31 @@ describe('CSS Support', () => {
})
})
})
})
describe
(
'Good Nested CSS Import from node_modules'
,
()
=>
{
const
appDir
=
join
(
fixturesDir
,
'npm-import-nested'
)
beforeAll
(
async
()
=>
{
await
remove
(
join
(
appDir
,
'.next'
))
})
it
(
'should build successfully'
,
async
()
=>
{
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{color:#00f}.test{color:red}"`
)
})
})
describe
(
'Bad CSS Import from node_modules'
,
()
=>
{
describe
(
'Bad CSS Import from node_modules'
,
()
=>
{
const
appDir
=
join
(
fixturesDir
,
'npm-import-bad'
)
const
appDir
=
join
(
fixturesDir
,
'npm-import-bad'
)
...
...
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