mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-28 23:24:13 +00:00
* fix(shadcn): fix transformRsc to account for ' * chore: add changeset --------- Co-authored-by: shadcn <m@shadcn.com>
114 lines
1.8 KiB
TypeScript
114 lines
1.8 KiB
TypeScript
import { expect, test } from "vitest"
|
|
|
|
import { transform } from "../../src/utils/transformers"
|
|
|
|
test("transform rsc", async () => {
|
|
expect(
|
|
await transform({
|
|
filename: "test.ts",
|
|
raw: `import * as React from "react"
|
|
import { Foo } from "bar"
|
|
`,
|
|
config: {
|
|
tsx: true,
|
|
rsc: true,
|
|
},
|
|
})
|
|
).toMatchSnapshot()
|
|
|
|
expect(
|
|
await transform({
|
|
filename: "test.ts",
|
|
raw: `"use client"
|
|
|
|
import * as React from "react"
|
|
import { Foo } from "bar"
|
|
`,
|
|
config: {
|
|
tsx: true,
|
|
rsc: true,
|
|
},
|
|
})
|
|
).toMatchSnapshot()
|
|
|
|
expect(
|
|
await transform({
|
|
filename: "test.ts",
|
|
raw: `"use client"
|
|
|
|
import * as React from "react"
|
|
import { Foo } from "bar"
|
|
`,
|
|
config: {
|
|
tsx: true,
|
|
rsc: false,
|
|
},
|
|
})
|
|
).toMatchSnapshot()
|
|
|
|
expect(
|
|
await transform({
|
|
filename: "test.ts",
|
|
raw: `"use foo"
|
|
|
|
import * as React from "react"
|
|
import { Foo } from "bar"
|
|
|
|
"use client"
|
|
`,
|
|
config: {
|
|
tsx: true,
|
|
rsc: false,
|
|
},
|
|
})
|
|
).toMatchSnapshot()
|
|
|
|
|
|
expect(
|
|
await transform({
|
|
filename: "test.ts",
|
|
raw: `'use client'
|
|
|
|
import * as React from 'react'
|
|
import { Foo } from 'bar'
|
|
`,
|
|
config: {
|
|
tsx: true,
|
|
rsc: true,
|
|
},
|
|
})
|
|
).toMatchSnapshot()
|
|
|
|
expect(
|
|
await transform({
|
|
filename: "test.ts",
|
|
raw: `'use client'
|
|
|
|
import * as React from 'react'
|
|
import { Foo } from 'bar'
|
|
`,
|
|
config: {
|
|
tsx: true,
|
|
rsc: false,
|
|
},
|
|
})
|
|
).toMatchSnapshot()
|
|
|
|
expect(
|
|
await transform({
|
|
filename: "test.ts",
|
|
raw: `'use foo'
|
|
|
|
import * as React from 'react'
|
|
import { Foo } from 'bar'
|
|
|
|
'use client'
|
|
`,
|
|
config: {
|
|
tsx: true,
|
|
rsc: false,
|
|
},
|
|
})
|
|
).toMatchSnapshot()
|
|
})
|