-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.test.ts
More file actions
54 lines (44 loc) · 1.4 KB
/
Copy pathutils.test.ts
File metadata and controls
54 lines (44 loc) · 1.4 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
import { jest } from '@jest/globals';
const mockedOs = {
platform: jest.fn(),
arch: jest.fn(),
};
jest.unstable_mockModule('node:os', () => mockedOs);
const { getBinaryPath, getDownloadObject } = await import('./utils.js');
const platforms: NodeJS.Platform[] = ['darwin', 'linux', 'win32'];
const architectures = ['arm', 'x32', 'x64'] as NodeJS.Architecture[];
const table = platforms.reduce(
(testSuites, platform) => [
...testSuites,
...architectures.map(
(arch) => [platform, 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 platform is %p', (platform) => {
beforeEach(() => {
jest.resetAllMocks();
mockedOs.platform.mockReturnValueOnce(platform);
});
it('returns CLI filepath', () => {
const directory = 'directory';
const name = 'name';
expect(getBinaryPath(directory, name)).toMatchSnapshot();
});
});
});