Home / File/ migrate.test.ts — tailwindcss Source File

migrate.test.ts — tailwindcss Source File

Architecture documentation for migrate.test.ts, a typescript file in the tailwindcss codebase. 7 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  930146af_7164_8be9_737f_e83f06ce8ce8["migrate.test.ts"]
  28a2f72d_350c_6647_bf9d_77c69e637045["default-map.ts"]
  930146af_7164_8be9_737f_e83f06ce8ce8 --> 28a2f72d_350c_6647_bf9d_77c69e637045
  cfb4af0e_7b2d_34a1_693a_90088443cfec["DefaultMap"]
  930146af_7164_8be9_737f_e83f06ce8ce8 --> cfb4af0e_7b2d_34a1_693a_90088443cfec
  472e1b98_afcf_f1f2_ad91_916d742bb731["version.ts"]
  930146af_7164_8be9_737f_e83f06ce8ce8 --> 472e1b98_afcf_f1f2_ad91_916d742bb731
  e39bed3f_bfbf_a8c6_90a0_aa2ce3be1ef4["migrate.ts"]
  930146af_7164_8be9_737f_e83f06ce8ce8 --> e39bed3f_bfbf_a8c6_90a0_aa2ce3be1ef4
  66c57db2_afd7_9e7b_cea6_76cdb074b086["migrateCandidate"]
  930146af_7164_8be9_737f_e83f06ce8ce8 --> 66c57db2_afd7_9e7b_cea6_76cdb074b086
  08129f89_e6ef_0092_629d_821c60228c89["node"]
  930146af_7164_8be9_737f_e83f06ce8ce8 --> 08129f89_e6ef_0092_629d_821c60228c89
  f1e05e5f_c1b2_a3f5_b2e8_3317b9243ac3["vitest"]
  930146af_7164_8be9_737f_e83f06ce8ce8 --> f1e05e5f_c1b2_a3f5_b2e8_3317b9243ac3
  style 930146af_7164_8be9_737f_e83f06ce8ce8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { __unstable__loadDesignSystem } from '@tailwindcss/node'
import { describe, expect, test, vi } from 'vitest'
import { DefaultMap } from '../../../../tailwindcss/src/utils/default-map'
import * as versions from '../../utils/version'
import { migrateCandidate as migrate } from './migrate'
vi.spyOn(versions, 'isMajor').mockReturnValue(false)

const designSystems = new DefaultMap((base: string) => {
  return new DefaultMap((input: string) => {
    return __unstable__loadDesignSystem(input, { base })
  })
})

const css = String.raw

describe.each([['default'], ['with-variant'], ['important'], ['prefix']])('%s', (strategy) => {
  let testName = '%s => %s (%#)'
  if (strategy === 'with-variant') {
    testName = testName.replaceAll('%s', 'focus:%s')
  } else if (strategy === 'important') {
    testName = testName.replaceAll('%s', '%s!')
  } else if (strategy === 'prefix') {
    testName = testName.replaceAll('%s', 'tw:%s')
  }

  // Basic input with minimal design system to keep the tests fast
  let input = css`
    @import 'tailwindcss' ${strategy === 'prefix' ? 'prefix(tw)' : ''};
    @theme {
      --*: initial;
      --spacing: 0.25rem;
      --color-red-500: red;

      /* Equivalent of blue-500/50 */
      --color-primary: color-mix(in oklab, oklch(62.3% 0.214 259.815) 50%, transparent);
    }
  `

  test.each([
    // Arbitrary property to named functional utility
    ['[color:red]', 'text-red-500'],

    // Promote data types to more specific utility if it exists
    ['bg-(position:--my-value)', 'bg-position-(--my-value)'],

    // Promote inferred data type to more specific utility if it exists
    ['bg-[123px]', 'bg-position-[123px]'],

    // Do not migrate bare values or arbitrary values to named values that are
    // deprecated
    ['order-[0]', 'order-0'],
    ['order-0', 'order-0'],

    // Migrate deprecated named values to bare values
    ['order-none', 'order-0'],

    // `-0` should not be migrated to `0`.
    //
    // This used to be a bug that translate `mt-[0px]` into `-mt-[0px]` because
    // `-mt-[0px]` translates to `margin-top: calc(0px * -1);` and therefore we
// ... (70 more lines)

Subdomains

Functions

Frequently Asked Questions

What does migrate.test.ts do?
migrate.test.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the CommandLineInterface domain, Codemods subdomain.
What functions are defined in migrate.test.ts?
migrate.test.ts defines 1 function(s): designSystems.
What does migrate.test.ts depend on?
migrate.test.ts imports 7 module(s): DefaultMap, default-map.ts, migrate.ts, migrateCandidate, node, version.ts, vitest.
Where is migrate.test.ts in the architecture?
migrate.test.ts is located at packages/@tailwindcss-upgrade/src/codemods/template/migrate.test.ts (domain: CommandLineInterface, subdomain: Codemods, 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