Repository: tailwindlabs/tailwindcss
File: packages/@tailwindcss-upgrade/src/codemods/template/migrate.test.ts (TypeScript)

Code before:
    ['order-none', 'order-0'],
  ])(testName, async (candidate, result) => {
    if (strategy === 'with-variant') {
      candidate = `focus:${candidate}`
      result = `focus:${result}`
    } else if (strategy === 'important') {
      candidate = `${candidate}!`
      result = `${result}!`
    } else if (strategy === 'prefix') {
      // Not only do we need to prefix the candidate, we also have to make
      // sure that we prefix all CSS variables.
      candidate = `tw:${candidate.replaceAll('var(--', 'var(--tw-')}`
      result = `tw:${result.replaceAll('var(--', 'var(--tw-')}`
    }

    let designSystem = await designSystems.get(__dirname).get(input)
    let migrated = await migrate(designSystem, {}, candidate)
    expect(migrated).toEqual(result)
  })

  test.each([
    ['order-[0]', 'order-0'],
    ['order-0', 'order-0'],

    // Do not migrate away `order-none` if it's customly defined and thus not
    // safe to migrate to `order-0`
    ['order-none', 'order-none'],
  ])(`${testName} with custom implementations`, async (candidate, result) => {
    if (strategy === 'with-variant') {
      candidate = `focus:${candidate}`
      result = `focus:${result}`
    } else if (strategy === 'important') {
      candidate = `${candidate}!`
      result = `${result}!`
    } else if (strategy === 'prefix') {
      // Not only do we need to prefix the candidate, we also have to make
      // sure that we prefix all CSS variables.
      candidate = `tw:${candidate.replaceAll('var(--', 'var(--tw-')}`
      result = `tw:${result.replaceAll('var(--', 'var(--tw-')}`
    }

    let localInput = css`
      ${input}

      @utility order-none {
        order: none; /* imagine this exists */
      }
    `

    let designSystem = await designSystems.get(__dirname).get(localInput)
    let migrated = await migrate(designSystem, {}, candidate)

Review comment (refactor):
```suggestion
    // Do not migrate `order-none` if defined as a custom utility as it is then
    // not safe to migrate to `order-0`
```

Code after:
    ['order-none', 'order-0'],
  ])(testName, async (candidate, result) => {
    if (strategy === 'with-variant') {
      candidate = `focus:${candidate}`
      result = `focus:${result}`
    } else if (strategy === 'important') {
      candidate = `${candidate}!`
      result = `${result}!`
    } else if (strategy === 'prefix') {
      // Not only do we need to prefix the candidate, we also have to make
      // sure that we prefix all CSS variables.
      candidate = `tw:${candidate.replaceAll('var(--', 'var(--tw-')}`
      result = `tw:${result.replaceAll('var(--', 'var(--tw-')}`
    }

    let designSystem = await designSystems.get(__dirname).get(input)
    let migrated = await migrate(designSystem, {}, candidate)
    expect(migrated).toEqual(result)
  })

  test.each([
    ['order-[0]', 'order-0'],
    ['order-0', 'order-0'],

    // Do not migrate `order-none` if defined as a custom utility as it is then
    // not safe to migrate to `order-0`
    ['order-none', 'order-none'],
  ])(`${testName} with custom implementations`, async (candidate, result) => {
    if (strategy === 'with-variant') {
      candidate = `focus:${candidate}`
      result = `focus:${result}`
    } else if (strategy === 'important') {
      candidate = `${candidate}!`
      result = `${result}!`
    } else if (strategy === 'prefix') {
      // Not only do we need to prefix the candidate, we also have to make
      // sure that we prefix all CSS variables.
      candidate = `tw:${candidate.replaceAll('var(--', 'var(--tw-')}`
      result = `tw:${result.replaceAll('var(--', 'var(--tw-')}`
    }

    let localInput = css`
      ${input}

      @utility order-none {
        order: none; /* imagine this exists */
      }
    `

    let designSystem = await designSystems.get(__dirname).get(localInput)
    let migrated = await migrate(designSystem, {}, candidate)