diff --git a/test/test/npm.test.ts b/test/test/npm.test.ts index 149e176..571ee1f 100644 --- a/test/test/npm.test.ts +++ b/test/test/npm.test.ts @@ -37,7 +37,7 @@ describe("license-auditor", () => { expect(errorCode).toBe(0); expect(output).toContain("245 licenses are compliant"); expect(output).toContain("2 packages are requiring manual checking"); - } + }, ); defaultTest( @@ -58,7 +58,7 @@ describe("license-auditor", () => { expect(output).toContain("245 licenses are compliant"); expect(output).toContain("1 license is unknown"); expect(output).toContain("2 packages are requiring manual checking"); - } + }, ); defaultTest( @@ -72,7 +72,7 @@ describe("license-auditor", () => { expect(errorCode).toBe(0); expect(output).toContain("77 licenses are compliant"); - } + }, ); legacyPeerDepsTest("legacy peer deps", async ({ testDirectory }) => { @@ -97,7 +97,7 @@ describe("license-auditor", () => { version: "1.0.0", license: "", }, - [{ name: "LICENSE-MIT", content: "MIT" }] + [{ name: "LICENSE-MIT", content: "MIT" }], ); const { output, errorCode } = await runCliCommand({ @@ -107,7 +107,7 @@ describe("license-auditor", () => { }); const jsonOutput = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); @@ -117,20 +117,20 @@ describe("license-auditor", () => { getWhitelistedLicenses( jsonOutput, ["testing-license-file"], - ["MIT"] - ).length + ["MIT"], + ).length, ).toBe(1); expect( getBlacklistedLicenses( jsonOutput, ["testing-license-file"], - ["MIT"] - ).length + ["MIT"], + ).length, ).toBe(0); expect( - getUnknownLicenses(jsonOutput, ["testing-license-file"]).length + getUnknownLicenses(jsonOutput, ["testing-license-file"]).length, ).toBe(0); - } + }, ); defaultTest( @@ -146,7 +146,7 @@ describe("license-auditor", () => { [ { name: "LICENSE-MIT", content: "MIT" }, { name: "LICENSE-WRONG", content: "WRONG" }, - ] + ], ); const { output, errorCode } = await runCliCommand({ @@ -156,7 +156,7 @@ describe("license-auditor", () => { }); const jsonOutput = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); @@ -165,16 +165,16 @@ describe("license-auditor", () => { expect( getNeedsUserVerificationLicenses(jsonOutput, [ "testing-license-file", - ]) + ]), ).toContainEqual( expect.objectContaining({ packageName: "testing-license-file@1.0.0", verificationMessage: expect.stringMatching( - /We've found few license files, but we could not match a license for some of them for package/ + /We've found few license files, but we could not match a license for some of them for package/, ), - }) + }), ); - } + }, ); }); @@ -188,7 +188,7 @@ describe("license-auditor", () => { version: "1.0.0", license: "", }, - [{ name: "LICENSE-WRONG", content: "WRONG" }] + [{ name: "LICENSE-WRONG", content: "WRONG" }], ); const { output, errorCode } = await runCliCommand({ @@ -198,27 +198,27 @@ describe("license-auditor", () => { }); const jsonOutput = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); expect(output).toContain("1 package is missing license information"); expect(output).toContain("2 packages are requiring manual checking"); expect(output).toContain( - "We’ve found a license file, but no matching licenses in" + "We’ve found a license file, but no matching licenses in", ); expect( - getNotFoundLicenses(jsonOutput, ["testing-license-file"]) + getNotFoundLicenses(jsonOutput, ["testing-license-file"]), ).toContainEqual( expect.objectContaining({ packageName: "testing-license-file@1.0.0", errorMessage: expect.stringMatching( - /License not found in package.json and in license file in/ + /License not found in package.json and in license file in/, ), - }) + }), ); - } + }, ); defaultTest( @@ -234,7 +234,7 @@ describe("license-auditor", () => { [ { name: "LICENSE-MIT", content: await getLicenseContent("MIT") }, { name: "LICENSE-ISC", content: await getLicenseContent("ISC") }, - ] + ], ); const { output, errorCode } = await runCliCommand({ @@ -244,7 +244,7 @@ describe("license-auditor", () => { }); const jsonOutput = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); @@ -252,7 +252,7 @@ describe("license-auditor", () => { expect(output).toContain("2 packages are requiring manual checking"); expect( - getWhitelistedLicenses(jsonOutput, ["testing-license-file"]) + getWhitelistedLicenses(jsonOutput, ["testing-license-file"]), ).toContainEqual( expect.objectContaining({ packageName: "testing-license-file@1.0.0", @@ -264,9 +264,9 @@ describe("license-auditor", () => { licenseId: "ISC", }), ]), - }) + }), ); - } + }, ); defaultTest( @@ -285,7 +285,7 @@ describe("license-auditor", () => { name: "LICENSE-GPL", content: await getLicenseContent("GPL-3.0-or-later"), }, - ] + ], ); const { output, errorCode } = await runCliCommand({ @@ -295,27 +295,29 @@ describe("license-auditor", () => { }); const jsonOutput = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); expect(output).toContain("3 packages are requiring manual checking"); expect(output).toContain( - "Some but not all licenses are whitelisted for package" + "Some but not all licenses are whitelisted for package", ); expect( - getNeedsUserVerificationLicenses(jsonOutput, ["testing-license-file"]) + getNeedsUserVerificationLicenses(jsonOutput, [ + "testing-license-file", + ]), ).toContainEqual( expect.objectContaining({ packageName: "testing-license-file@1.0.0", verificationMessage: expect.stringMatching( - /Some but not all licenses are whitelisted for package/ + /Some but not all licenses are whitelisted for package/, ), - }) + }), ); expect( - getBlacklistedLicenses(jsonOutput, ["testing-license-file"]) + getBlacklistedLicenses(jsonOutput, ["testing-license-file"]), ).toContainEqual( expect.objectContaining({ packageName: "testing-license-file@1.0.0", @@ -327,9 +329,9 @@ describe("license-auditor", () => { licenseId: "GPL-3.0-or-later", }), ]), - }) + }), ); - } + }, ); defaultTest( @@ -347,23 +349,23 @@ describe("license-auditor", () => { }); const jsonOutput = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); expect(output).toContain("1 package is missing license information"); expect( - getNotFoundLicenses(jsonOutput, ["testing-no-license"]) + getNotFoundLicenses(jsonOutput, ["testing-no-license"]), ).toContainEqual( expect.objectContaining({ packageName: "testing-no-license@1.0.0", errorMessage: expect.stringMatching( - /License not found in package.json and in license file/ + /License not found in package.json and in license file/, ), - }) + }), ); - } + }, ); }); @@ -381,7 +383,7 @@ describe("license-auditor", () => { `; const configFilePath = path.resolve( testDirectory, - "license-auditor.config.ts" + "license-auditor.config.ts", ); await fs.writeFile(configFilePath, invalidConfig); @@ -395,7 +397,7 @@ describe("license-auditor", () => { expect(output).toContain("Expected array, received string"); expect(output).toContain("Expected array, received number"); expect(output).toContain("Expected object, received string"); - } + }, ); defaultTest( @@ -404,7 +406,7 @@ describe("license-auditor", () => { const packageDirectory = path.resolve( testDirectory, "node_modules", - "a-library-without-package-json" + "a-library-without-package-json", ); await fs.mkdir(packageDirectory, { recursive: true }); @@ -416,7 +418,7 @@ describe("license-auditor", () => { expect(output).toContain("1 package returned error:"); expect(output).toContain("package.json not found for package at"); - } + }, ); testErrorHandling( @@ -425,7 +427,7 @@ describe("license-auditor", () => { const packageDirectory = path.resolve( testDirectory, "node_modules", - "a-library-with-empty-package-json" + "a-library-with-empty-package-json", ); await fs.mkdir(packageDirectory, { recursive: true }); @@ -440,7 +442,7 @@ describe("license-auditor", () => { }); expect(output).toContain("1 package is missing license information"); - } + }, ); }); describe("filter-regex flag", () => { @@ -454,7 +456,7 @@ describe("license-auditor", () => { version: "1.0.0", license: "", }, - [{ name: "LICENSE-MIT", content: "MIT" }] + [{ name: "LICENSE-MIT", content: "MIT" }], ); await addPackage( @@ -464,7 +466,7 @@ describe("license-auditor", () => { version: "1.0.0", license: "", }, - [{ name: "LICENSE-MIT", content: "MIT" }] + [{ name: "LICENSE-MIT", content: "MIT" }], ); const { output, errorCode } = await runCliCommand({ @@ -475,7 +477,7 @@ describe("license-auditor", () => { expect(errorCode).toBe(0); expect(output).toContain("246 licenses are compliant"); - } + }, ); defaultTest( @@ -488,7 +490,7 @@ describe("license-auditor", () => { version: "1.0.0", license: "", }, - [{ name: "LICENSE-MIT", content: "MIT" }] + [{ name: "LICENSE-MIT", content: "MIT" }], ); await addPackage( @@ -498,7 +500,7 @@ describe("license-auditor", () => { version: "1.0.0", license: "", }, - [{ name: "LICENSE-MIT", content: "MIT" }] + [{ name: "LICENSE-MIT", content: "MIT" }], ); const { output, errorCode } = await runCliCommand({ @@ -509,7 +511,7 @@ describe("license-auditor", () => { expect(errorCode).toBe(0); expect(output).toContain("245 licenses are compliant"); - } + }, ); }); @@ -524,7 +526,7 @@ describe("license-auditor", () => { version: "1.0.0", license: "MIT", }, - [{ name: "LICENSE-MIT", content: "MIT" }] + [{ name: "LICENSE-MIT", content: "MIT" }], ); await addPackage( @@ -534,7 +536,7 @@ describe("license-auditor", () => { version: "1.0.0", license: "", }, - [{ name: "LICENSE-MIT", content: "MIT" }] + [{ name: "LICENSE-MIT", content: "MIT" }], ); const { output, errorCode } = await runCliCommand({ @@ -544,18 +546,18 @@ describe("license-auditor", () => { }); const jsonOutput: JsonResults = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); expect(output).toContain("246 licenses are compliant"); const okStatus = jsonOutput.whitelist.find( - (result) => result.packageName === "testing-license-file@1.0.0" + (result) => result.packageName === "testing-license-file@1.0.0", ); expect(okStatus?.verificationStatus).toBe("ok"); - } + }, ); defaultTest( @@ -573,7 +575,7 @@ describe("license-auditor", () => { }); const jsonOutput: JsonResults = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); @@ -581,13 +583,13 @@ describe("license-auditor", () => { const someButNotAllLicensesWhitelisted = jsonOutput.needsUserVerification.find( - (result) => result.packageName === "testing-license-file@1.0.0" + (result) => result.packageName === "testing-license-file@1.0.0", ); expect(someButNotAllLicensesWhitelisted?.verificationMessage).toContain( - "Some but not all licenses are whitelisted for package" + "Some but not all licenses are whitelisted for package", ); - } + }, ); defaultTest( @@ -603,7 +605,7 @@ describe("license-auditor", () => { [ { name: "LICENSE-MIT", content: "MIT" }, { name: "LICENSE", content: "nonsense" }, - ] + ], ); const { output, errorCode } = await runCliCommand({ @@ -613,7 +615,7 @@ describe("license-auditor", () => { }); const jsonOutput: JsonResults = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); @@ -621,13 +623,13 @@ describe("license-auditor", () => { const someButNotAllLicensesWhitelisted = jsonOutput.needsUserVerification.find( - (result) => result.packageName === "testing-license-file@1.0.0" + (result) => result.packageName === "testing-license-file@1.0.0", ); expect(someButNotAllLicensesWhitelisted?.verificationMessage).toContain( - "We've found few license files" + "We've found few license files", ); - } + }, ); }); describe("--production flag", () => { @@ -641,7 +643,7 @@ describe("license-auditor", () => { version: "1.0.0", license: "MIT", }, - [{ name: "LICENSE", content: "nonsense" }] + [{ name: "LICENSE", content: "nonsense" }], ); const { output, errorCode } = await runCliCommand({ @@ -651,7 +653,7 @@ describe("license-auditor", () => { }); const jsonOutput: JsonResults = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); @@ -659,13 +661,13 @@ describe("license-auditor", () => { const licenseFileExistsButUnknownLicense = jsonOutput.needsUserVerification.find( - (result) => result.packageName === "testing-license-file@1.0.0" + (result) => result.packageName === "testing-license-file@1.0.0", ); expect( - licenseFileExistsButUnknownLicense?.verificationMessage + licenseFileExistsButUnknownLicense?.verificationMessage, ).toContain("We’ve found a license file, but no matching licenses"); - } + }, ); defaultTest( @@ -683,19 +685,19 @@ describe("license-auditor", () => { }); const jsonOutput: JsonResults = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); expect(output).toContain("246 licenses are compliant"); const licenseFileNotFound = jsonOutput.whitelist.find( - (result) => result.packageName === "testing-license-file@1.0.0" + (result) => result.packageName === "testing-license-file@1.0.0", ); expect(licenseFileNotFound?.verificationStatus).toContain( - "licenseFileNotFound" + "licenseFileNotFound", ); - } + }, ); describe("source", () => { defaultTest( @@ -713,17 +715,17 @@ describe("license-auditor", () => { }); const jsonOutput: JsonResults = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); expect(output).toContain("246 licenses are compliant"); const addedPackage = jsonOutput.whitelist.find( - (result) => result.packageName === "test-package@1.0.0" + (result) => result.packageName === "test-package@1.0.0", ); expect(addedPackage?.licenses[0].source).toBe("package.json-license"); - } + }, ); defaultTest( @@ -741,20 +743,20 @@ describe("license-auditor", () => { }); const jsonOutput: JsonResults = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); expect(output).toContain("246 licenses are compliant"); const addedPackage = jsonOutput.whitelist.find( - (result) => result.packageName === "test-package@1.0.0" + (result) => result.packageName === "test-package@1.0.0", ); expect(addedPackage?.licenses[0].source).toBe( - "package.json-licenses" + "package.json-licenses", ); - } + }, ); defaultTest( @@ -772,18 +774,18 @@ describe("license-auditor", () => { }); const jsonOutput: JsonResults = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); expect(output).toContain("246 licenses are compliant"); const addedPackage = jsonOutput.whitelist.find( - (result) => result.packageName === "test-package@1.0.0" + (result) => result.packageName === "test-package@1.0.0", ); expect(addedPackage?.licenses[0].source).toBe("package.json-legacy"); - } + }, ); defaultTest( @@ -801,20 +803,20 @@ describe("license-auditor", () => { }); const jsonOutput: JsonResults = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); expect(output).toContain("246 licenses are compliant"); const addedPackage = jsonOutput.whitelist.find( - (result) => result.packageName === "test-package@1.0.0" + (result) => result.packageName === "test-package@1.0.0", ); expect(addedPackage?.licenses[0].source).toBe( - "package.json-license-expression" + "package.json-license-expression", ); - } + }, ); defaultTest( @@ -827,7 +829,7 @@ describe("license-auditor", () => { version: "1.0.0", license: "", }, - [{ name: "LICENSE", content: "MIT" }] + [{ name: "LICENSE", content: "MIT" }], ); const { output, errorCode } = await runCliCommand({ @@ -837,20 +839,20 @@ describe("license-auditor", () => { }); const jsonOutput: JsonResults = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); expect(output).toContain("246 licenses are compliant"); const addedPackage = jsonOutput.whitelist.find( - (result) => result.packageName === "test-package@1.0.0" + (result) => result.packageName === "test-package@1.0.0", ); expect(addedPackage?.licenses[0].source).toBe( - "license-file-content-keywords" + "license-file-content-keywords", ); - } + }, ); defaultTest( @@ -869,7 +871,7 @@ describe("license-auditor", () => { content: 'MIT License\n\nCopyright (c) \n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n', }, - ] + ], ); const { output, errorCode } = await runCliCommand({ @@ -879,18 +881,18 @@ describe("license-auditor", () => { }); const jsonOutput: JsonResults = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); expect(output).toContain("246 licenses are compliant"); const addedPackage = jsonOutput.whitelist.find( - (result) => result.packageName === "test-package@1.0.0" + (result) => result.packageName === "test-package@1.0.0", ); expect(addedPackage?.licenses[0].source).toBe("license-file-content"); - } + }, ); }); @@ -910,18 +912,18 @@ describe("license-auditor", () => { }); const jsonOutput: JsonResults = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); expect(output).toContain("78 licenses are compliant"); const addedPackage = jsonOutput.whitelist.find( - (result) => result.packageName === "test-dep@1.0.0" + (result) => result.packageName === "test-dep@1.0.0", ); expect(addedPackage).toBeDefined(); - } + }, ); defaultTest("omits devDependencies", async ({ testDirectory }) => { @@ -933,7 +935,7 @@ describe("license-auditor", () => { license: "MIT", }, [], - true + true, ); const { output, errorCode } = await runCliCommand({ @@ -943,14 +945,14 @@ describe("license-auditor", () => { }); const jsonOutput: JsonResults = await readJsonFile( - path.join(testDirectory, "license-auditor.results.json") + path.join(testDirectory, "license-auditor.results.json"), ); expect(errorCode).toBe(0); expect(output).toContain("77 licenses are compliant"); const addedPackage = jsonOutput.whitelist.find( - (result) => result.packageName === "test-dep@1.0.0" + (result) => result.packageName === "test-dep@1.0.0", ); expect(addedPackage).toBeUndefined(); @@ -969,6 +971,6 @@ describe("license-auditor", () => { expect(errorCode).toBe(1); expect(output).toContain("Unable to resolve project dependencies."); - } + }, ); });