-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcli-commands.test.ts
More file actions
55 lines (48 loc) · 1.95 KB
/
Copy pathcli-commands.test.ts
File metadata and controls
55 lines (48 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { describe, expect, it } from 'vitest'
import { buildCLICommandOptions } from '@/lib/cli-commands'
import type { ManifestPlatformElement } from '@/types/manifests'
const macOSPlatform: ManifestPlatformElement = { os: 'macOS', installPath: null }
const windowsPlatform: ManifestPlatformElement = { os: 'Windows', installPath: null }
const linuxPlatform: ManifestPlatformElement = { os: 'Linux', installPath: null }
const basePlatforms = [macOSPlatform, windowsPlatform, linuxPlatform]
describe('CLI command options', () => {
it('preserves platform-specific install commands', () => {
const options = buildCLICommandOptions({
platforms: [
{ ...macOSPlatform, installCommand: 'curl install.sh | bash', launchCommand: 'agy' },
{ ...windowsPlatform, installCommand: 'irm install.ps1 | iex', launchCommand: 'agy' },
{ ...linuxPlatform, installCommand: 'curl install.sh | bash', launchCommand: 'agy' },
],
})
expect(options).toHaveLength(3)
expect(options.find(option => option.os === 'Windows')?.installCommand).toBe(
'irm install.ps1 | iex'
)
})
it('collapses commands only when every platform uses the same values', () => {
const options = buildCLICommandOptions({
platforms: basePlatforms.map(platform => ({
...platform,
installCommand: 'npm install -g example',
launchCommand: 'example',
})),
})
expect(options).toEqual([
{
os: null,
installCommand: 'npm install -g example',
launchCommand: 'example',
},
])
})
it('keeps platform labels when a supported platform has no recorded command', () => {
const options = buildCLICommandOptions({
platforms: [
{ ...macOSPlatform, installCommand: 'curl install.sh | bash' },
windowsPlatform,
{ ...linuxPlatform, installCommand: 'curl install.sh | bash' },
],
})
expect(options.map(option => option.os)).toEqual(['macOS', 'Linux'])
})
})