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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
import { TEST_HOST } from 'helpers/test_constants';
import {
DEFAULT_PLATFORM,
LINUX_PLATFORM,
MACOS_PLATFORM,
WINDOWS_PLATFORM,
} from '~/ci/runner/constants';
import {
commandPrompt,
registerCommand,
runCommand,
installScript,
platformArchitectures,
} from '~/ci/runner/components/registration/utils';
import { mockAuthenticationToken } from '../../mock_data';
describe('registration utils', () => {
beforeEach(() => {
window.gon.gitlab_url = TEST_HOST;
});
describe.each([LINUX_PLATFORM, MACOS_PLATFORM, WINDOWS_PLATFORM])(
'for "%s" platform',
(platform) => {
it('commandPrompt is correct', () => {
expect(commandPrompt({ platform })).toMatchSnapshot();
});
it('registerCommand is correct', () => {
expect(
registerCommand({
platform,
token: mockAuthenticationToken,
}),
).toMatchSnapshot();
expect(registerCommand({ platform })).toMatchSnapshot();
});
it('runCommand is correct', () => {
expect(runCommand({ platform })).toMatchSnapshot();
});
},
);
describe('for missing platform', () => {
it('commandPrompt uses the default', () => {
const expected = commandPrompt({ platform: DEFAULT_PLATFORM });
expect(commandPrompt({ platform: null })).toEqual(expected);
expect(commandPrompt({ platform: undefined })).toEqual(expected);
});
it('registerCommand uses the default', () => {
const expected = registerCommand({
platform: DEFAULT_PLATFORM,
token: mockAuthenticationToken,
});
expect(registerCommand({ platform: null, token: mockAuthenticationToken })).toEqual(expected);
expect(registerCommand({ platform: undefined, token: mockAuthenticationToken })).toEqual(
expected,
);
});
it('runCommand uses the default', () => {
const expected = runCommand({ platform: DEFAULT_PLATFORM });
expect(runCommand({ platform: null })).toEqual(expected);
expect(runCommand({ platform: undefined })).toEqual(expected);
});
});
describe.each([LINUX_PLATFORM, MACOS_PLATFORM, WINDOWS_PLATFORM])(
'for "%s" platform',
(platform) => {
describe('platformArchitectures', () => {
it('returns correct list of architectures', () => {
expect(platformArchitectures({ platform })).toMatchSnapshot();
});
});
describe('installScript', () => {
const architectures = platformArchitectures({ platform });
it.each(architectures)('is correct for "%s" architecture', (architecture) => {
expect(installScript({ platform, architecture })).toMatchSnapshot();
});
});
},
);
});
|