import { describe, expect, it } from 'vitest' import { migrateIconsFile } from './migrate-icons' describe('migrateIconsFile', () => { it('should replace radix icons with lucide icons', async () => { const input = ` import { CheckIcon, CloseIcon } from "@radix-ui/react-icons" import { Something } from "other-package" export function Component() { return (
) }` expect( await migrateIconsFile(input, 'radix', 'lucide', { Check: { lucide: 'Check', radix: 'CheckIcon', }, X: { lucide: 'X', radix: 'CloseIcon', }, }), ).toMatchInlineSnapshot(` "import { Something } from "other-package" import { Check, X } from "lucide-react"; export function Component() { return (
) }" `) }) it('should return null if no radix icons are found', async () => { const input = ` import { Something } from "other-package" export function Component() { return
No icons here
}` expect(await migrateIconsFile(input, 'lucide', 'radix', {})) .toMatchInlineSnapshot(` "import { Something } from "other-package" export function Component() { return
No icons here
}" `) }) it('should handle mixed icon imports from different packages', async () => { const input = ` import { CheckIcon } from "@radix-ui/react-icons" import { AlertCircle } from "lucide-react" import { Something } from "other-package" import { Cross2Icon } from "@radix-ui/react-icons" export function Component() { return (
) }` expect( await migrateIconsFile(input, 'radix', 'lucide', { Check: { lucide: 'Check', radix: 'CheckIcon', }, X: { lucide: 'X', radix: 'Cross2Icon', }, }), ).toMatchInlineSnapshot(` "import { AlertCircle } from "lucide-react" import { Something } from "other-package" import { Check, X } from "lucide-react"; export function Component() { return (
) }" `) }) it('should preserve all props and children on icons', async () => { const input = ` import { CheckIcon, Cross2Icon } from "@radix-ui/react-icons" export function Component() { return (
Child content
) }` expect( await migrateIconsFile(input, 'radix', 'lucide', { Check: { lucide: 'Check', radix: 'CheckIcon', }, X: { lucide: 'X', radix: 'Cross2Icon', }, }), ).toMatchInlineSnapshot(` "import { Check, X } from "lucide-react"; export function Component() { return (
Child content
) }" `) }) })