tailwindcss/tests/jit/raw-content.test.js
Adam Wathan 4bfa21f756
Support border-opacity with default border color (#4277)
* Move border reset to borderColor plugin, support opacity

* Update JIT tests

* Don't use opacity variable for default border color when borderOpacity is disabled

* Fix tests
2021-05-08 06:59:14 -04:00

92 lines
2.1 KiB
JavaScript

import postcss from 'postcss'
import fs from 'fs'
import path from 'path'
beforeEach(() => {
jest.resetModules()
})
function run(tailwind, input, config = {}) {
return postcss(tailwind(config)).process(input, {
from: path.resolve(__filename),
})
}
test('raw content', () => {
let tailwind = require('../../src/jit/index.js').default
let config = {
mode: 'jit',
purge: [{ raw: fs.readFileSync(path.resolve(__dirname, './raw-content.test.html'), 'utf8') }],
corePlugins: { preflight: false },
theme: {},
plugins: [],
}
let css = `
@tailwind base;
@tailwind components;
@tailwind utilities;
`
return run(tailwind, css, config).then((result) => {
let expectedPath = path.resolve(__dirname, './raw-content.test.css')
let expected = fs.readFileSync(expectedPath, 'utf8')
expect(result.css).toMatchFormattedCss(expected)
})
})
test('raw content with extension', () => {
let tailwind = require('../../src/jit/index.js').default
let config = {
mode: 'jit',
purge: {
content: [
{
raw: fs.readFileSync(path.resolve(__dirname, './raw-content.test.html'), 'utf8'),
extension: 'html',
},
],
options: {
extractors: [
{
extractor: () => [],
extensions: ['html'],
},
],
},
},
corePlugins: { preflight: false },
theme: {},
plugins: [],
}
let css = `
@tailwind base;
@tailwind components;
@tailwind utilities;
`
return run(tailwind, css, config).then((result) => {
expect(result.css).toMatchFormattedCss(`
*,
::before,
::after {
--tw-border-opacity: 1;
border-color: rgba(229, 231, 235, var(--tw-border-opacity));
}
* {
--tw-shadow: 0 0 #0000;
--tw-ring-inset: var(--tw-empty, /*!*/ /*!*/);
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgba(59, 130, 246, 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
}
`)
})
})