import path from 'node:path' import { describe, expect, it } from 'vitest' import { tsdownConfig } from '../tsdown.js' describe('tsdownConfig()', () => { describe('copy', () => { it('resolves a string entry relative to src', () => { const config = tsdownConfig('node/index', { copy: ['client/components/global/*.vue'], }) expect(config.copy).toStrictEqual([ { from: './src/client/components/global/*.vue', flatten: false }, ]) }) it('resolves tuple entries relative to src and the output directory', () => { const config = tsdownConfig('node/index', { copy: [['assets/'], ['types/global.d.ts', 'types']], }) expect(config.copy).toStrictEqual([ { from: './src/assets/', flatten: false }, { from: './src/types/global.d.ts', to: './dist/types' }, ]) }) it('resolves every path of an array from', () => { const config = tsdownConfig('node/index', { copy: [ { from: ['assets/**/*', '!assets/**/*.map'], to: 'assets', flatten: false, }, ], }) expect(config.copy).toStrictEqual([ { from: ['./src/assets/**/*', '!./src/assets/**/*.map'], to: './dist/assets', flatten: false, }, ]) }) it('keeps absolute and already prefixed paths unchanged', () => { const absolutePath = path.resolve('LICENSE') const config = tsdownConfig('node/index', { copy: ['./src/LICENSE', { from: absolutePath, to: './dist/LICENSE' }], }) expect(config.copy).toStrictEqual([ { from: './src/LICENSE', flatten: false }, { from: absolutePath, to: './dist/LICENSE' }, ]) }) }) })