migrate-prefix.test.ts — tailwindcss Source File
Architecture documentation for migrate-prefix.test.ts, a typescript file in the tailwindcss codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 14c5b5eb_ad93_c522_2553_30e94134dbf5["migrate-prefix.test.ts"] fff09679_e13c_392d_23bb_cebc04ddb008["version.ts"] 14c5b5eb_ad93_c522_2553_30e94134dbf5 --> fff09679_e13c_392d_23bb_cebc04ddb008 d13948d4_4434_bf78_9916_1ba327123c94["migrate-prefix.ts"] 14c5b5eb_ad93_c522_2553_30e94134dbf5 --> d13948d4_4434_bf78_9916_1ba327123c94 087d2224_9aa6_c6e5_3a75_d99cf251cb04["migratePrefix"] 14c5b5eb_ad93_c522_2553_30e94134dbf5 --> 087d2224_9aa6_c6e5_3a75_d99cf251cb04 92f2d961_72a4_d195_92d7_2e66972f8894["node"] 14c5b5eb_ad93_c522_2553_30e94134dbf5 --> 92f2d961_72a4_d195_92d7_2e66972f8894 696bd648_5f24_1b59_8e8b_7a97a692869e["vitest"] 14c5b5eb_ad93_c522_2553_30e94134dbf5 --> 696bd648_5f24_1b59_8e8b_7a97a692869e style 14c5b5eb_ad93_c522_2553_30e94134dbf5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { __unstable__loadDesignSystem } from '@tailwindcss/node'
import { describe, expect, test, vi } from 'vitest'
import * as versions from '../../utils/version'
import { migratePrefix } from './migrate-prefix'
vi.spyOn(versions, 'isMajor').mockReturnValue(true)
describe('for projects with configured prefix', () => {
test.each([
['tw-flex', 'tw:flex'],
['-tw-mr-4', 'tw:-mr-4'],
['!tw-flex', 'tw:flex!'],
['tw-text-red-500/50', 'tw:text-red-500/50'],
// With variants
['hover:tw-flex', 'tw:hover:flex'],
['hover:-tw-mr-4', 'tw:hover:-mr-4'],
['hover:!tw-flex', 'tw:hover:flex!'],
// Does not change un-prefixed candidates
['flex', 'flex'],
['hover:flex', 'hover:flex'],
// Adds prefix to arbitrary candidates
['[color:red]', 'tw:[color:red]'],
// `.group` and `.peer` classes
['tw-group', 'tw:group'],
['tw-group/foo', 'tw:group/foo'],
['tw-peer', 'tw:peer'],
['tw-peer/foo', 'tw:peer/foo'],
])('%s => %s', async (candidate, result) => {
let designSystem = await __unstable__loadDesignSystem('@import "tailwindcss" prefix(tw);', {
base: __dirname,
})
expect(migratePrefix(designSystem, { prefix: 'tw-' }, candidate)).toEqual(result)
})
})
test('can handle complex prefix separators', async () => {
let designSystem = await __unstable__loadDesignSystem('@import "tailwindcss" prefix(tw);', {
base: __dirname,
})
expect(migratePrefix(designSystem, { prefix: 'tw__' }, 'tw__flex')).toEqual('tw:flex')
})
describe('for projects without configured prefix', () => {
test('ignores candidates with prefixes', async () => {
let designSystem = await __unstable__loadDesignSystem('@import "tailwindcss";', {
base: __dirname,
})
expect(migratePrefix(designSystem, {}, 'tw-flex')).toEqual('tw-flex')
})
})
Domain
Dependencies
- migrate-prefix.ts
- migratePrefix
- node
- version.ts
- vitest
Source
Frequently Asked Questions
What does migrate-prefix.test.ts do?
migrate-prefix.test.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the UpgradeToolkit domain.
What does migrate-prefix.test.ts depend on?
migrate-prefix.test.ts imports 5 module(s): migrate-prefix.ts, migratePrefix, node, version.ts, vitest.
Where is migrate-prefix.test.ts in the architecture?
migrate-prefix.test.ts is located at packages/@tailwindcss-upgrade/src/codemods/template/migrate-prefix.test.ts (domain: UpgradeToolkit, directory: packages/@tailwindcss-upgrade/src/codemods/template).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free