Skip to content

Commit

Permalink
Disable dark mode by default, rename config option to darkMode (#2631)
Browse files Browse the repository at this point in the history
* Disable dark mode by default, rename config option to `darkMode`

* Rebuild fixtures
  • Loading branch information
adamwathan committed Oct 21, 2020
1 parent fc5c9ce commit b92f033
Show file tree
Hide file tree
Showing 9 changed files with 270,517 additions and 471,370 deletions.
43 changes: 34 additions & 9 deletions __tests__/darkMode.test.js
Expand Up @@ -45,7 +45,7 @@ test('user-defined dark mode variants do not stack', () => {
})
})

test('generating dark mode variants uses the media strategy by default', () => {
test('dark mode variants can be generated using the class strategy', () => {
const input = `
@variants dark {
.text-red {
Expand All @@ -67,7 +67,7 @@ test('generating dark mode variants uses the media strategy by default', () => {

expect.assertions(2)

return run(input).then((result) => {
return run(input, { darkMode: 'media' }).then((result) => {
expect(result.css).toMatchCss(expected)
expect(result.warnings().length).toBe(0)
})
Expand Down Expand Up @@ -95,7 +95,7 @@ test('dark mode variants can be generated even when the user has their own plugi

expect.assertions(2)

return run(input, { plugins: [] }).then((result) => {
return run(input, { darkMode: 'media', plugins: [] }).then((result) => {
expect(result.css).toMatchCss(expected)
expect(result.warnings().length).toBe(0)
})
Expand All @@ -121,7 +121,7 @@ test('dark mode variants can be generated using the class strategy', () => {

expect.assertions(2)

return run(input, { dark: 'class' }).then((result) => {
return run(input, { darkMode: 'class' }).then((result) => {
expect(result.css).toMatchCss(expected)
expect(result.warnings().length).toBe(0)
})
Expand Down Expand Up @@ -150,6 +150,29 @@ test('dark mode variants can be disabled', () => {
})
})

test('dark mode variants are disabled by default', () => {
const input = `
@variants dark {
.text-red {
color: red;
}
}
`

const expected = `
.text-red {
color: red;
}
`

expect.assertions(2)

return run(input).then((result) => {
expect(result.css).toMatchCss(expected)
expect(result.warnings().length).toBe(0)
})
})

test('dark mode variants stack with other variants', () => {
const input = `
@variants responsive, dark, hover, focus {
Expand Down Expand Up @@ -228,10 +251,12 @@ test('dark mode variants stack with other variants', () => {

expect.assertions(2)

return run(input, { theme: { screens: { sm: '500px', lg: '800px' } } }).then((result) => {
expect(result.css).toMatchCss(expected)
expect(result.warnings().length).toBe(0)
})
return run(input, { darkMode: 'media', theme: { screens: { sm: '500px', lg: '800px' } } }).then(
(result) => {
expect(result.css).toMatchCss(expected)
expect(result.warnings().length).toBe(0)
}
)
})

test('dark mode variants stack with other variants when using the class strategy', () => {
Expand Down Expand Up @@ -324,7 +349,7 @@ test('dark mode variants stack with other variants when using the class strategy

expect.assertions(2)

return run(input, { dark: 'class', theme: { screens: { sm: '500px', lg: '800px' } } }).then(
return run(input, { darkMode: 'class', theme: { screens: { sm: '500px', lg: '800px' } } }).then(
(result) => {
expect(result.css).toMatchCss(expected)
expect(result.warnings().length).toBe(0)
Expand Down

0 comments on commit b92f033

Please sign in to comment.