Clean up tests for TS

This commit is contained in:
Adam Wathan 2022-12-01 10:39:05 -05:00 • committed by Robin Malfait
parent 7da6d23c4d
commit a92f798117
No known key found for this signature in database
GPG key ID: 92F53D68B9041AFE
11 changed files with 38 additions and 34 deletions

View file

@ -109,7 +109,8 @@
"\\.test\\.skip\\.js$"
],
"transform": {
"\\.js$": "@swc/jest"
"\\.js$": "@swc/jest",
"\\.ts$": "@swc/jest"
}
},
"engines": {

View file

@ -1,7 +1,7 @@
#!/usr/bin/env node
if (process.env.OXIDE) {
module.exports = require('./oxide/cli.js')
module.exports = require('./oxide/cli')
} else {
module.exports = require('./cli/index.js')
module.exports = require('./cli/index')
}

View file

@ -1,5 +1,5 @@
if (process.env.OXIDE) {
module.exports = require('./oxide/postcss-plugin.js')
module.exports = require('./oxide/postcss-plugin')
} else {
module.exports = require('./plugin.js')
module.exports = require('./plugin')
}

View file

@ -172,20 +172,10 @@
<div class="rounded-[11px]"></div>
<div
class="
rounded-t-[var(--radius)]
rounded-r-[var(--radius)]
rounded-b-[var(--radius)]
rounded-l-[var(--radius)]
"
class="rounded-t-[var(--radius)] rounded-r-[var(--radius)] rounded-b-[var(--radius)] rounded-l-[var(--radius)]"
></div>
<div
class="
rounded-tr-[var(--radius)]
rounded-br-[var(--radius)]
rounded-bl-[var(--radius)]
rounded-tl-[var(--radius)]
"
class="rounded-tr-[var(--radius)] rounded-br-[var(--radius)] rounded-bl-[var(--radius)] rounded-tl-[var(--radius)]"
></div>
<div class="border-[#f00]"></div>
@ -382,7 +372,6 @@
<div class="content-['>']"></div>
<!-- Balancing issues, this is not checking the validity of the actual value, but purely syntax-wise -->
<div class="w-[do-not-generate-this]w-[it-is-invalid-syntax]"></div>
<!-- INVALID -->
<div class="grid-cols-[[linename],1fr,auto]"></div>
<!-- VALID -->

View file

@ -1,8 +1,11 @@
import fs from 'fs'
import path from 'path'
import { env } from '../src/lib/sharedState'
import { run, html, css } from './util/run'
let oxideSkip = env.OXIDE ? test.skip : test
test('arbitrary values', () => {
let config = {
content: [path.resolve(__dirname, './arbitrary-values.test.html')],
@ -16,6 +19,23 @@ test('arbitrary values', () => {
})
})
oxideSkip(
'should only detect classes with arbitrary values that are properly terminated after the arbitrary value',
() => {
let config = {
content: [
{
raw: html`<div class="w-[do-not-generate-this]w-[it-is-invalid-syntax]"></div>`,
},
],
}
return run('@tailwind utilities', config).then((result) => {
return expect(result.css).toMatchFormattedCss(css``)
})
}
)
it('should be possible to differentiate between decoration utilities', () => {
let config = {
content: [

View file

@ -1,12 +1,10 @@
import { run, html, css } from './util/run'
import log from '../src/util/log'
let warn
beforeEach(() => {
warn = jest.spyOn(
process.env.OXIDE ? require('../lib/util/log').default : require('../src/util/log').default,
'warn'
)
warn = jest.spyOn(log, 'warn')
})
afterEach(() => warn.mockClear())

View file

@ -83,8 +83,7 @@ it('re-uses the context across multiple files with the same config', async () =>
expect(dependencies[3]).toEqual([path.resolve(__dirname, 'context-reuse.tailwind.config.js')])
// And none of this should have resulted in multiple contexts being created
let localSharedState = process.env.OXIDE ? require('../lib/lib/sharedState') : sharedState
expect(localSharedState.contextSourcesMap.size).toBe(1)
expect(sharedState.contextSourcesMap.size).toBe(1)
})
it('updates layers when any CSS containing @tailwind directives changes', async () => {

View file

@ -3,6 +3,7 @@ import path from 'path'
import postcss from 'postcss'
import plugin from '../src/lib/evaluateTailwindFunctions'
import { run as runFull, css, html } from './util/run'
import log from '../src/util/log'
function run(input, opts = {}) {
return postcss([
@ -1269,10 +1270,7 @@ describe('context dependent', () => {
let warn
beforeEach(() => {
warn = jest.spyOn(
process.env.OXIDE ? require('../lib/util/log').default : require('../src/util/log').default,
'warn'
)
warn = jest.spyOn(log, 'warn')
})
afterEach(() => warn.mockClear())

View file

@ -90,8 +90,7 @@ describe('duplicate elision', () => {
`
let result = await run(input, config)
let localSharedState = process.env.OXIDE ? require('../lib/lib/sharedState') : sharedState
let allContexts = Array.from(localSharedState.contextMap.values())
let allContexts = Array.from(sharedState.contextMap.values())
let context = allContexts[allContexts.length - 1]

View file

@ -1,10 +1,10 @@
import { run, css, html } from './util/run'
import log from '../src/util/log'
let warn
beforeEach(() => {
let log = process.env.OXIDE ? require('../lib/util/log') : require('../src/util/log')
warn = jest.spyOn(log.default, 'warn')
warn = jest.spyOn(log, 'warn')
})
afterEach(() => {

View file

@ -1,10 +1,10 @@
import { html, run, css } from './util/run'
import log from '../src/util/log'
let warn
beforeEach(() => {
let log = process.env.OXIDE ? require('../lib/util/log') : require('../src/util/log')
warn = jest.spyOn(log.default, 'warn')
warn = jest.spyOn(log, 'warn')
})
afterEach(() => {