|
| 1 | +import { describe, expect, it } from 'vitest' |
| 2 | + |
| 3 | +import { |
| 4 | + getPackageManagerExecuteCommand, |
| 5 | + getPackageManagerInstallCommand, |
| 6 | + getPackageManagerScriptCommand, |
| 7 | +} from '../src/package-manager.js' |
| 8 | +import { formatCommand } from '../src/utils.js' |
| 9 | + |
| 10 | +describe('getPackageManagerScriptCommand', () => { |
| 11 | + it('yarn', () => { |
| 12 | + expect(formatCommand(getPackageManagerScriptCommand('yarn', ['dev']))).toBe( |
| 13 | + 'yarn run dev', |
| 14 | + ) |
| 15 | + }) |
| 16 | + it('pnpm', () => { |
| 17 | + expect(formatCommand(getPackageManagerScriptCommand('pnpm', ['dev']))).toBe( |
| 18 | + 'pnpm dev', |
| 19 | + ) |
| 20 | + }) |
| 21 | + it('bun', () => { |
| 22 | + expect(formatCommand(getPackageManagerScriptCommand('bun', ['dev']))).toBe( |
| 23 | + 'bunx --bun run dev', |
| 24 | + ) |
| 25 | + }) |
| 26 | + it('deno', () => { |
| 27 | + expect(formatCommand(getPackageManagerScriptCommand('deno', ['dev']))).toBe( |
| 28 | + 'deno task dev', |
| 29 | + ) |
| 30 | + }) |
| 31 | + it('npm', () => { |
| 32 | + expect(formatCommand(getPackageManagerScriptCommand('npm', ['dev']))).toBe( |
| 33 | + 'npm run dev', |
| 34 | + ) |
| 35 | + }) |
| 36 | +}) |
| 37 | + |
| 38 | +describe('getPackageManagerExecuteCommand', () => { |
| 39 | + it('yarn', () => { |
| 40 | + expect( |
| 41 | + formatCommand( |
| 42 | + getPackageManagerExecuteCommand('yarn', 'shadcn', ['add', 'button']), |
| 43 | + ), |
| 44 | + ).toBe('yarn dlx shadcn add button') |
| 45 | + }) |
| 46 | + it('pnpm', () => { |
| 47 | + expect( |
| 48 | + formatCommand( |
| 49 | + getPackageManagerExecuteCommand('pnpm', 'shadcn', ['add', 'button']), |
| 50 | + ), |
| 51 | + ).toBe('pnpx shadcn add button') |
| 52 | + }) |
| 53 | + it('bun', () => { |
| 54 | + expect( |
| 55 | + formatCommand( |
| 56 | + getPackageManagerExecuteCommand('bun', 'shadcn', ['add', 'button']), |
| 57 | + ), |
| 58 | + ).toBe('bunx --bun shadcn add button') |
| 59 | + }) |
| 60 | + it('deno', () => { |
| 61 | + expect( |
| 62 | + formatCommand( |
| 63 | + getPackageManagerExecuteCommand('deno', 'shadcn', ['add', 'button']), |
| 64 | + ), |
| 65 | + ).toBe('deno run npm:shadcn add button') |
| 66 | + }) |
| 67 | + it('npm', () => { |
| 68 | + expect( |
| 69 | + formatCommand( |
| 70 | + getPackageManagerExecuteCommand('npm', 'shadcn', ['add', 'button']), |
| 71 | + ), |
| 72 | + ).toBe('npx shadcn add button') |
| 73 | + }) |
| 74 | +}) |
| 75 | + |
| 76 | +describe('getPackageManagerInstallCommand', () => { |
| 77 | + it('yarn install', () => { |
| 78 | + expect(formatCommand(getPackageManagerInstallCommand('yarn'))).toBe( |
| 79 | + 'yarn install', |
| 80 | + ) |
| 81 | + }) |
| 82 | + it('pnpm install', () => { |
| 83 | + expect(formatCommand(getPackageManagerInstallCommand('pnpm'))).toBe( |
| 84 | + 'pnpm install', |
| 85 | + ) |
| 86 | + }) |
| 87 | + it('bun install', () => { |
| 88 | + expect(formatCommand(getPackageManagerInstallCommand('bun'))).toBe( |
| 89 | + 'bun install', |
| 90 | + ) |
| 91 | + }) |
| 92 | + it('deno install', () => { |
| 93 | + expect(formatCommand(getPackageManagerInstallCommand('deno'))).toBe( |
| 94 | + 'deno install', |
| 95 | + ) |
| 96 | + }) |
| 97 | + it('npm install', () => { |
| 98 | + expect(formatCommand(getPackageManagerInstallCommand('npm'))).toBe( |
| 99 | + 'npm install', |
| 100 | + ) |
| 101 | + }) |
| 102 | + |
| 103 | + it('yarn install radix-ui', () => { |
| 104 | + expect( |
| 105 | + formatCommand(getPackageManagerInstallCommand('yarn', 'radix-ui')), |
| 106 | + ).toBe('yarn add radix-ui') |
| 107 | + }) |
| 108 | + it('pnpm install radix-ui', () => { |
| 109 | + expect( |
| 110 | + formatCommand(getPackageManagerInstallCommand('pnpm', 'radix-ui')), |
| 111 | + ).toBe('pnpm add radix-ui') |
| 112 | + }) |
| 113 | + it('bun install radix-ui', () => { |
| 114 | + expect( |
| 115 | + formatCommand(getPackageManagerInstallCommand('bun', 'radix-ui')), |
| 116 | + ).toBe('bun install radix-ui') |
| 117 | + }) |
| 118 | + it('deno install radix-ui', () => { |
| 119 | + expect( |
| 120 | + formatCommand(getPackageManagerInstallCommand('deno', 'radix-ui')), |
| 121 | + ).toBe('deno install radix-ui') |
| 122 | + }) |
| 123 | + it('npm install radix-ui', () => { |
| 124 | + expect( |
| 125 | + formatCommand(getPackageManagerInstallCommand('npm', 'radix-ui')), |
| 126 | + ).toBe('npm install radix-ui') |
| 127 | + }) |
| 128 | + |
| 129 | + it('yarn install vitest in dev mode', () => { |
| 130 | + expect( |
| 131 | + formatCommand(getPackageManagerInstallCommand('yarn', 'vitest', true)), |
| 132 | + ).toBe('yarn add vitest --dev') |
| 133 | + }) |
| 134 | + it('pnpm install vitest in dev mode', () => { |
| 135 | + expect( |
| 136 | + formatCommand(getPackageManagerInstallCommand('pnpm', 'vitest', true)), |
| 137 | + ).toBe('pnpm add vitest --dev') |
| 138 | + }) |
| 139 | + it('bun install vitest in dev mode', () => { |
| 140 | + expect( |
| 141 | + formatCommand(getPackageManagerInstallCommand('bun', 'vitest', true)), |
| 142 | + ).toBe('bun install vitest -D') |
| 143 | + }) |
| 144 | + it('deno install vitest in dev mode', () => { |
| 145 | + expect( |
| 146 | + formatCommand(getPackageManagerInstallCommand('deno', 'vitest', true)), |
| 147 | + ).toBe('deno install vitest -D') |
| 148 | + }) |
| 149 | + it('npm install vitest in dev mode', () => { |
| 150 | + expect( |
| 151 | + formatCommand(getPackageManagerInstallCommand('npm', 'vitest', true)), |
| 152 | + ).toBe('npm install vitest -D') |
| 153 | + }) |
| 154 | +}) |
0 commit comments