import { describe, expect, it } from 'vitest'

import { transformTailwindContent } from '../../../src/utils/updaters/update-tailwind-content'

const SHARED_CONFIG = {
  $schema: 'https://shadcn-vue.com/schema.json',
  style: 'new-york',
  rsc: true,
  tsx: true,
  tailwind: {
    config: 'tailwind.config.ts',
    css: 'app/globals.css',
    baseColor: 'slate',
    cssVariables: true,
  },
  aliases: {
    components: '@/components',
    utils: '@/lib/utils',
  },
  resolvedPaths: {
    cwd: '.',
    tailwindConfig: 'tailwind.config.ts',
    tailwindCss: 'app/globals.css',
    components: './components',
    utils: './lib/utils',
    ui: './components/ui',
  },
}

describe('transformTailwindContent -> content property', () => {
  it('should add content property if not in config', async () => {
    expect(
      await transformTailwindContent(
        `import type { Config } from 'tailwindcss'

const config: Config = {
  content: [
    "./pages/**/*.{js,ts,jsx,tsx,mdx}",
    "./components/**/*.{js,ts,jsx,tsx,mdx}",
    "./app/**/*.{js,ts,jsx,tsx,mdx}",
  ],
  theme: {
    extend: {
      backgroundImage: {
        "gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
        "gradient-conic":
          "conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
      },
    },
  },
  plugins: [],
}
export default config
  `,
        ['./foo/**/*.{js,ts,jsx,tsx,mdx}', './bar/**/*.{js,ts,jsx,tsx,mdx}'],
        {
          config: SHARED_CONFIG,
        },
      ),
    ).toMatchSnapshot()
  })

  it('should NOT add content property if already in config', async () => {
    expect(
      await transformTailwindContent(
        `import type { Config } from 'tailwindcss'

const config: Config = {
  content: [
    "./pages/**/*.{js,ts,jsx,tsx,mdx}",
    "./components/**/*.{js,ts,jsx,tsx,mdx}",
    "./app/**/*.{js,ts,jsx,tsx,mdx}",
  ],
  theme: {
    extend: {
      backgroundImage: {
        "gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
        "gradient-conic":
          "conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
      },
    },
  },
  plugins: [],
}
export default config
  `,
        ['./app/**/*.{js,ts,jsx,tsx,mdx}', './bar/**/*.{js,ts,jsx,tsx,mdx}'],
        {
          config: SHARED_CONFIG,
        },
      ),
    ).toMatchSnapshot()
  })
})
