Skip to content

Commit

Permalink
Test filter license when undefined to fix error in /discussions/1255,…
Browse files Browse the repository at this point in the history
… add unite tests for undefined license and multiple licenses and update git ignore to add line for IntelliJ module files - Signed-off-by: Cory Fitzpatrick [email protected]
  • Loading branch information
Cory Fitzpatrick committed Jul 18, 2024
1 parent 39e3ac8 commit d559111
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,6 @@ roots/
.python-version
build/
.mise.toml

# Ignore IntelliJ IDEA module file
cdxgen.iml
2 changes: 1 addition & 1 deletion utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ export function getLicenses(pkg) {
license = [license];
}
return adjustLicenseInformation(
license.map((l) => {
license.filter((l) => l !== undefined).map((l) => {
let licenseContent = {};
if (typeof l === "string" || l instanceof String) {
if (
Expand Down
20 changes: 20 additions & 0 deletions utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2398,6 +2398,26 @@ test("get licenses", () => {
expression: "GPL-3.0-only WITH Classpath-exception-2.0",
},
]);

licenses = getLicenses({
license: [
"GPL-3.0-only WITH Classpath-exception-2.0",
"NOT-GPL-2.1+"
]
});
expect(licenses).toEqual([
{
expression: "GPL-3.0-only WITH Classpath-exception-2.0",
},
{
expression: "NOT-GPL-2.1+",
}
]);

licenses = getLicenses({
license: undefined,
});
expect(licenses).toEqual(undefined);
});

test("parsePkgJson", async () => {
Expand Down

0 comments on commit d559111

Please sign in to comment.