mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
* WIP * WIP * Finish combining JIT and AOT plugins Still lots of clean up that can be done in some of the more complex ones, but at least it's one file per plugin now. * Remove unused import * Fix AOT generation bugs * Move corePlugins/index.js to corePlugins.js * Convert JIT files to ESM * Move tests * Reorder core plugins to match JIT order * Update AOT apply tests * Unify utils * Combine plugin lists to one single source of truth * Finish resolving merge conflicts, fix tests Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
74 lines
1.9 KiB
JavaScript
74 lines
1.9 KiB
JavaScript
import * as utils from '../src/cli/utils'
|
|
|
|
describe('cli utils', () => {
|
|
describe('parseCliParams', () => {
|
|
it('parses CLI parameters', () => {
|
|
const result = utils.parseCliParams(['a', 'b', '-c', 'd'])
|
|
|
|
expect(result).toEqual(['a', 'b'])
|
|
})
|
|
})
|
|
|
|
describe('parseCliOptions', () => {
|
|
it('parses CLI options', () => {
|
|
const result = utils.parseCliOptions(['a', '-b', 'c'], { test: ['b'] })
|
|
|
|
expect(result).toEqual({ test: ['c'] })
|
|
})
|
|
|
|
it('parses multiple types of options', () => {
|
|
const result = utils.parseCliOptions(['a', '-b', 'c', '--test', 'd', '-test', 'e'], {
|
|
test: ['test', 'b'],
|
|
})
|
|
|
|
expect(result).toEqual({ test: ['c', 'd', 'e'] })
|
|
})
|
|
|
|
it('ignores unknown options', () => {
|
|
const result = utils.parseCliOptions(['a', '-b', 'c'], {})
|
|
|
|
expect(result).toEqual({})
|
|
})
|
|
|
|
it('maps options', () => {
|
|
const result = utils.parseCliOptions(['a', '-b', 'c', '-d', 'e'], { test: ['b', 'd'] })
|
|
|
|
expect(result).toEqual({ test: ['c', 'e'] })
|
|
})
|
|
|
|
it('parses undefined options', () => {
|
|
const result = utils.parseCliOptions(['a'], { test: ['b'] })
|
|
|
|
expect(result).toEqual({ test: undefined })
|
|
})
|
|
|
|
it('parses flags', () => {
|
|
const result = utils.parseCliOptions(['a', '-b'], { test: ['b'] })
|
|
|
|
expect(result).toEqual({ test: [] })
|
|
})
|
|
|
|
it('accepts multiple values per option', () => {
|
|
const result = utils.parseCliOptions(['a', '-b', 'c', 'd', '-e', 'f', '-g', 'h'], {
|
|
test: ['b', 'g'],
|
|
})
|
|
|
|
expect(result).toEqual({ test: ['c', 'd', 'h'] })
|
|
})
|
|
})
|
|
|
|
describe('getSimplePath', () => {
|
|
it('strips leading ./', () => {
|
|
const result = utils.getSimplePath('./test')
|
|
|
|
expect(result).toEqual('test')
|
|
})
|
|
|
|
it('returns unchanged path if it does not begin with ./', () => {
|
|
const result = utils.getSimplePath('../test')
|
|
|
|
expect(result).toEqual('../test')
|
|
})
|
|
})
|
|
})
|