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 3fb6e8d3_05d9_63e2_c1c9_76cdf725f56a["migrate-prefix.test.ts"] 472e1b98_afcf_f1f2_ad91_916d742bb731["version.ts"] 3fb6e8d3_05d9_63e2_c1c9_76cdf725f56a --> 472e1b98_afcf_f1f2_ad91_916d742bb731 e4e5ac2c_0d58_689d_0ad6_7086823787f1["migrate-prefix.ts"] 3fb6e8d3_05d9_63e2_c1c9_76cdf725f56a --> e4e5ac2c_0d58_689d_0ad6_7086823787f1 7a457be5_eaef_02ce_7bc4_4e0317ecd8ce["migratePrefix"] 3fb6e8d3_05d9_63e2_c1c9_76cdf725f56a --> 7a457be5_eaef_02ce_7bc4_4e0317ecd8ce 08129f89_e6ef_0092_629d_821c60228c89["node"] 3fb6e8d3_05d9_63e2_c1c9_76cdf725f56a --> 08129f89_e6ef_0092_629d_821c60228c89 f1e05e5f_c1b2_a3f5_b2e8_3317b9243ac3["vitest"] 3fb6e8d3_05d9_63e2_c1c9_76cdf725f56a --> f1e05e5f_c1b2_a3f5_b2e8_3317b9243ac3 style 3fb6e8d3_05d9_63e2_c1c9_76cdf725f56a 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 CommandLineInterface 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: CommandLineInterface, 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