-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add `transform` and `extract` APIs * make svelte transform part of the transformer stuff
- Loading branch information
1 parent
26454f7
commit 232cd97
Showing
5 changed files
with
432 additions
and
29 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
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,93 @@ | ||
import postcss from 'postcss' | ||
import path from 'path' | ||
|
||
function run(input, config = {}) { | ||
jest.resetModules() | ||
const tailwind = require('../../src/jit/index.js').default | ||
return postcss(tailwind(config)).process(input, { | ||
from: path.resolve(__filename), | ||
}) | ||
} | ||
|
||
function customTransformer(content) { | ||
return content.replace(/uppercase/g, 'lowercase') | ||
} | ||
|
||
const css = ` | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
` | ||
|
||
test('transform function', () => { | ||
let config = { | ||
mode: 'jit', | ||
purge: { | ||
content: [{ raw: '<div class="uppercase"></div>' }], | ||
transform: customTransformer, | ||
}, | ||
corePlugins: { preflight: false, borderColor: false, ringWidth: false, boxShadow: false }, | ||
theme: {}, | ||
plugins: [], | ||
} | ||
|
||
return run(css, config).then((result) => { | ||
expect(result.css).toMatchFormattedCss(` | ||
.lowercase { | ||
text-transform: lowercase; | ||
} | ||
`) | ||
}) | ||
}) | ||
|
||
test('transform.DEFAULT', () => { | ||
let config = { | ||
mode: 'jit', | ||
purge: { | ||
content: [{ raw: '<div class="uppercase"></div>' }], | ||
transform: { | ||
DEFAULT: customTransformer, | ||
}, | ||
}, | ||
corePlugins: { preflight: false, borderColor: false, ringWidth: false, boxShadow: false }, | ||
theme: {}, | ||
plugins: [], | ||
} | ||
|
||
return run(css, config).then((result) => { | ||
expect(result.css).toMatchFormattedCss(` | ||
.lowercase { | ||
text-transform: lowercase; | ||
} | ||
`) | ||
}) | ||
}) | ||
|
||
test('transform.{extension}', () => { | ||
let config = { | ||
mode: 'jit', | ||
purge: { | ||
content: [ | ||
{ raw: '<div class="uppercase"></div>', extension: 'html' }, | ||
{ raw: '<div class="uppercase"></div>', extension: 'php' }, | ||
], | ||
transform: { | ||
html: customTransformer, | ||
}, | ||
}, | ||
corePlugins: { preflight: false, borderColor: false, ringWidth: false, boxShadow: false }, | ||
theme: {}, | ||
plugins: [], | ||
} | ||
|
||
return run(css, config).then((result) => { | ||
expect(result.css).toMatchFormattedCss(` | ||
.uppercase { | ||
text-transform: uppercase; | ||
} | ||
.lowercase { | ||
text-transform: lowercase; | ||
} | ||
`) | ||
}) | ||
}) |
Oops, something went wrong.