Skip to content

Commit

Permalink
Test Custom Properties in CSS Modules (#10007)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Jan 9, 2020
1 parent d0957e3 commit a5ae018
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import styles from './styles.module.css'

export default function() {
return <div>{JSON.stringify(styles)}</div>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
h1 {
--color: red;
}

h1 {
color: var(--color);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import styles from './styles.module.css'

export default function() {
return <div>{JSON.stringify(styles)}</div>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:root {
--color: red;
}

h1 {
color: var(--color);
}
34 changes: 34 additions & 0 deletions test/integration/css-features/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,40 @@ describe('Custom Properties: Pass-Through Modern', () => {
})
})

describe('Custom Properties: Fail for :root {} in CSS Modules', () => {
const appDir = join(fixturesDir, 'cp-global-modules')

beforeAll(async () => {
await remove(join(appDir, '.next'))
})

it('should fail to build', async () => {
const { stderr } = await nextBuild(appDir, [], {
stderr: true,
})
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('pages/styles.module.css')
expect(stderr).toContain('CssSyntax error: Selector ":root" is not pure')
})
})

describe('Custom Properties: Fail for global element in CSS Modules', () => {
const appDir = join(fixturesDir, 'cp-el-modules')

beforeAll(async () => {
await remove(join(appDir, '.next'))
})

it('should fail to build', async () => {
const { stderr } = await nextBuild(appDir, [], {
stderr: true,
})
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('pages/styles.module.css')
expect(stderr).toContain('CssSyntax error: Selector "h1" is not pure')
})
})

describe('CSS Modules: Import Global CSS', () => {
const appDir = join(fixturesDir, 'module-import-global')

Expand Down

0 comments on commit a5ae018

Please sign in to comment.