Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export default class GitHubProject {
constructor(options) {
const { owner, number, fields = {} } = options;

if (Number.isNaN(number)) {
throw new TypeError("The number option must be a valid number");
}

// set octokit either from `options.octokit` or `options.token`
const octokit =
"token" in options
Expand Down
12 changes: 12 additions & 0 deletions test/constructor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,15 @@ test("constructor with token", (t) => {

t.true(project.octokit instanceof Octokit);
});

test("rejects NaN as the number option", (t) => {
t.throws(
() =>
new GitHubProject({
owner: "owner",
number: NaN,
octokit: new Octokit(),
}),
{ message: "The number option must be a valid number" },
);
});