-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.test.ts
More file actions
50 lines (41 loc) · 1.28 KB
/
Copy pathutils.test.ts
File metadata and controls
50 lines (41 loc) · 1.28 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
import os from 'os';
import { getBinaryPath, getDownloadObject } from './utils';
jest.mock('os');
const mockedOs = jest.mocked(os);
const platforms: NodeJS.Platform[] = ['darwin', 'linux', 'win32'];
const architectures = ['arm', 'x32', 'x64'] as NodeJS.Architecture[];
const table = platforms.reduce(
(testSuites, os) => [
...testSuites,
...architectures.map(
(arch) => [os, arch] as [NodeJS.Platform, NodeJS.Architecture],
),
],
[] as [NodeJS.Platform, NodeJS.Architecture][],
);
describe('getDownloadObject', () => {
describe.each(table)('when OS is %p and arch is %p', (os, arch) => {
const version = '2.27.0';
beforeEach(() => {
jest.resetAllMocks();
mockedOs.platform.mockReturnValueOnce(os);
mockedOs.arch.mockReturnValueOnce(arch);
});
it('gets download object', () => {
expect(getDownloadObject(version)).toMatchSnapshot();
});
});
});
describe('getBinaryPath', () => {
describe.each(platforms)('when OS is %p', (os) => {
beforeEach(() => {
jest.resetAllMocks();
mockedOs.platform.mockReturnValueOnce(os);
});
it('returns CLI filepath', () => {
const directory = 'directory';
const name = 'name';
expect(getBinaryPath(directory, name)).toMatchSnapshot();
});
});
});