Fix tests
This commit is contained in:
parent
311b8936ac
commit
8dffc4c95f
2 changed files with 22 additions and 7 deletions
|
|
@ -1,17 +1,32 @@
|
|||
import dedent from 'dedent'
|
||||
import postcss from 'postcss'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { Stylesheet } from '../migrate'
|
||||
import { Stylesheet } from '../stylesheet'
|
||||
import { formatNodes } from './format-nodes'
|
||||
import { migrateAtLayerUtilities } from './migrate-at-layer-utilities'
|
||||
|
||||
const css = dedent
|
||||
|
||||
function migrate(stylesheet: Stylesheet | string) {
|
||||
if (typeof stylesheet === 'string') {
|
||||
stylesheet = {
|
||||
content: stylesheet,
|
||||
root: postcss.parse(stylesheet),
|
||||
async function migrate(
|
||||
data:
|
||||
| Stylesheet
|
||||
| string
|
||||
| {
|
||||
root: postcss.Root
|
||||
layers?: string[]
|
||||
},
|
||||
) {
|
||||
let stylesheet: Stylesheet
|
||||
|
||||
if (typeof data === 'string') {
|
||||
stylesheet = await Stylesheet.fromString(data)
|
||||
} else if (data instanceof Stylesheet) {
|
||||
stylesheet = data
|
||||
} else {
|
||||
stylesheet = await Stylesheet.fromRoot(data.root)
|
||||
|
||||
for (let layer of data.layers ?? []) {
|
||||
stylesheet.layers.add(layer)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { type AtRule, type Comment, type Plugin, type Rule } from 'postcss'
|
||||
import SelectorParser from 'postcss-selector-parser'
|
||||
import { segment } from '../../../tailwindcss/src/utils/segment'
|
||||
import type { Stylesheet } from '../migrate'
|
||||
import { Stylesheet } from '../stylesheet'
|
||||
import { walk, WalkAction, walkDepth } from '../utils/walk'
|
||||
|
||||
export function migrateAtLayerUtilities(stylesheet: Stylesheet): Plugin {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue