-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchoice-generation.spec.ts
52 lines (47 loc) · 1.37 KB
/
choice-generation.spec.ts
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
import { applySelectedScriptsOnChoicesFromCache, createChoices } from './choice-generation'
import { Project } from './interfaces'
const createMockProjects = (): Array<Project> => [
{
projectFolder: 'projectFolder',
packageName: 'packageName',
shouldPublish: false,
reviewCategory: 'reviewCategory',
packageJson: {
name: 'string',
version: 'string',
main: 'string',
description: 'string',
author: 'string',
devDependencies: {},
scripts: { build: 'echo building' }
}
}
]
describe('choice-generation', () => {
test('should convert a project into a choice', async () => {
const { choices, allScriptNames } = createChoices(createMockProjects())
expect(choices).toHaveLength(1)
expect(allScriptNames).toHaveLength(1)
expect(allScriptNames).toEqual(['build'])
})
test('should populate initial scripts on choices', async () => {
const { choices } = createChoices(createMockProjects())
applySelectedScriptsOnChoicesFromCache(
choices,
{
packages: [
{
packageName: 'packageName',
script: 'build',
scriptExecutable: 'npm',
scriptCommand: ['run']
}
],
cliVersion: '0.11.0'
},
() => true
)
expect(choices[0].initial).toBeDefined()
expect(choices[0].initial).toEqual(['build'])
})
})