forked from sparkletown/sparkle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
package-lock.test.ts
41 lines (34 loc) · 1.32 KB
/
package-lock.test.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
const { readFileSync } = require("fs");
const _ = require("lodash");
describe("package-lock.json", () => {
const packageLockJson = JSON.parse(
readFileSync("./package-lock.json", "utf8")
);
/**
* This test allows us to failfast when npm v7 is used, until we are ready for it
*/
test("has lockfileVersion 1", () => {
expect(packageLockJson.lockfileVersion).toBe(1);
});
/**
* Ensure that fontawesome deps requirements are kept in alignment to avoid weird breakages.
*/
describe("@fortawesome/fontawesome-*", () => {
test("all use a common version of @fortawesome/fontawesome-common-types", () => {
const faCommonTypes =
packageLockJson.dependencies[`@fortawesome/fontawesome-common-types`];
const extractRequiredCommonTypesVersion = (dependencyKey) => {
const requiresObj =
packageLockJson.dependencies[dependencyKey].requires || {};
return requiresObj["@fortawesome/fontawesome-common-types"];
};
const requiredCommonTypes = Object.keys(packageLockJson.dependencies)
.filter((key) => key.startsWith("@fortawesome"))
.map(extractRequiredCommonTypesVersion)
.filter((key) => !!key);
expect(_.uniq(requiredCommonTypes)).toEqual(
expect.arrayContaining([`^${faCommonTypes.version}`])
);
});
});
});