-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added extra valid test case for missing property - Fix documentation - Fix linting errors
- Loading branch information
1 parent
47ccb5a
commit 84289f4
Showing
5 changed files
with
120 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { generateReportData, rule } from "../../rules/valid-license.js"; | ||
import { ruleTester } from "./ruleTester.js"; | ||
|
||
ruleTester.run("valid-license", rule, { | ||
invalid: [ | ||
// Invalid with single valid value | ||
{ | ||
code: JSON.stringify({ | ||
license: "CC BY-SA", | ||
name: "some-test-package", | ||
}), | ||
errors: [ | ||
{ | ||
data: generateReportData(["GPL"]), | ||
messageId: "invalidValue", | ||
}, | ||
], | ||
options: ["GPL"], | ||
}, | ||
// Invalid with multiple valid values | ||
{ | ||
code: JSON.stringify({ | ||
license: "Apache", | ||
name: "some-test-package", | ||
}), | ||
errors: [ | ||
{ | ||
data: generateReportData(["MIT", "GPL"]), | ||
messageId: "invalidValue", | ||
}, | ||
], | ||
options: [["MIT", "GPL"]], | ||
}, | ||
// Invalid property type | ||
{ | ||
code: JSON.stringify({ | ||
license: 1234, | ||
name: "some-test-package", | ||
}), | ||
errors: [ | ||
{ | ||
data: generateReportData(["GPL"]), | ||
messageId: "nonString", | ||
}, | ||
], | ||
options: ["GPL"], | ||
}, | ||
], | ||
valid: [ | ||
// Valid value from single valid value | ||
{ | ||
code: JSON.stringify({ | ||
license: "Apache", | ||
name: "some-test-package", | ||
}), | ||
options: ["Apache"], | ||
}, | ||
// Valid value from multiple valid values | ||
{ | ||
code: JSON.stringify({ | ||
license: "GPL", | ||
name: "some-test-package", | ||
}), | ||
options: [["MIT", "GPL"]], | ||
}, | ||
// Missing property | ||
{ | ||
code: JSON.stringify({ | ||
name: "some-test-package", | ||
}), | ||
options: [["MIT", "GPL"]], | ||
}, | ||
], | ||
}); |