-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to disable specific features
- Loading branch information
Showing
4 changed files
with
94 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`disabled-features does not transform light/dark if lightDarkFunction is disabled 1`] = ` | ||
" | ||
.card { | ||
color: light-dark(#000, #fff); | ||
} | ||
" | ||
`; | ||
|
||
exports[`disabled-features does not transform rem if rem function is disabled 1`] = ` | ||
" | ||
.card { | ||
padding: rem(32px); | ||
} | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { testTransform } from './utils'; | ||
|
||
const rem = ` | ||
.card { | ||
padding: rem(32px); | ||
} | ||
`; | ||
|
||
const lightDark = ` | ||
.card { | ||
color: light-dark(#000, #fff); | ||
} | ||
`; | ||
|
||
describe('disabled-features', () => { | ||
it('does not transform rem if rem function is disabled', async () => { | ||
const res = await testTransform(rem, { | ||
features: { remEmFunctions: false }, | ||
}); | ||
expect(res.css).toMatchSnapshot(); | ||
}); | ||
|
||
it('does not transform light/dark if lightDarkFunction is disabled', async () => { | ||
const res = await testTransform(lightDark, { | ||
features: { lightDarkFunction: false }, | ||
}); | ||
expect(res.css).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import postcss from 'postcss'; | ||
import type { Options } from '../preset'; | ||
const preset = require('../preset'); | ||
|
||
export function testTransform(input: string, options?: Record<string, any>) { | ||
export function testTransform(input: string, options?: Options) { | ||
return postcss([preset(options)]).process(input, { from: undefined }); | ||
} |