-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathutils.unit.test.ts
More file actions
86 lines (79 loc) · 2.41 KB
/
Copy pathutils.unit.test.ts
File metadata and controls
86 lines (79 loc) · 2.41 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
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
import { describe, expect, it } from 'vitest';
import { normalizeConfig } from './utils.js';
describe('normalizeConfig', () => {
it('should return checks object', async () => {
await expect(
normalizeConfig({ packageManager: 'npm' }),
).resolves.toStrictEqual(
expect.objectContaining({
checks: ['audit', 'outdated'],
}),
);
});
it('should return depGroups object', async () => {
await expect(
normalizeConfig({ packageManager: 'npm' }),
).resolves.toStrictEqual(
expect.objectContaining({
depGroups: ['prod', 'dev'],
}),
);
});
it('should throw if no package manager is detected', async () => {
await expect(normalizeConfig(undefined)).rejects.toThrow(
'Could not detect package manager. Please provide it in the js-packages plugin config.',
);
});
it('should return npm packageManager object if packageManager name is npm', async () => {
await expect(
normalizeConfig({ packageManager: 'npm' }),
).resolves.toStrictEqual(
expect.objectContaining({
packageManager: expect.objectContaining({
slug: 'npm',
command: 'npm',
name: 'npm',
}),
}),
);
});
it('should return yarn-classic packageManager object if packageManager name is yarn-classic', async () => {
await expect(
normalizeConfig({ packageManager: 'yarn-classic' }),
).resolves.toStrictEqual(
expect.objectContaining({
packageManager: expect.objectContaining({
slug: 'yarn-classic',
command: 'yarn',
name: 'Yarn v1',
}),
}),
);
});
it('should return yarn-modern packageManager object if packageManager name is yarn-modern', async () => {
await expect(
normalizeConfig({ packageManager: 'yarn-modern' }),
).resolves.toStrictEqual(
expect.objectContaining({
packageManager: expect.objectContaining({
slug: 'yarn-modern',
command: 'yarn',
name: 'Yarn v2+',
}),
}),
);
});
it('should return pnpm packageManager object if packageManager name is pnpm', async () => {
await expect(
normalizeConfig({ packageManager: 'pnpm' }),
).resolves.toStrictEqual(
expect.objectContaining({
packageManager: expect.objectContaining({
slug: 'pnpm',
command: 'pnpm',
name: 'pnpm',
}),
}),
);
});
});