-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support iteration fields (#95)
Following the issue #94 I created, here is the start of solution. I'm not used to Typescript so sorry if I make rookie mistakes. :) Closes #94 --------- Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
- Loading branch information
Showing
10 changed files
with
537 additions
and
5 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
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
Large diffs are not rendered by default.
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,34 @@ | ||
// @ts-check | ||
|
||
/** | ||
* Prepare state in order to record fixtures for test.js. Returns array of arguments that will be passed | ||
* passed as `test(project, ...arguments)`. | ||
* | ||
* @param {import("@octokit/openapi-types").components["schemas"]["repository"]} repository | ||
* @param {import("@octokit/core").Octokit} octokit | ||
* @param {import("../../..").default<{text: string, number: number, date: string, singleSelect: "One" | "Two" | "Three", iteration: "Iteration 1" | "Iteration 2" | "Iteration 3"}>} project | ||
* @returns {Promise<[string]>} | ||
*/ | ||
export async function prepare(repository, octokit, project) { | ||
// create a test issue | ||
const { data: issue } = await octokit.request( | ||
"POST /repos/{owner}/{repo}/issues", | ||
{ | ||
owner: repository.owner.login, | ||
repo: repository.name, | ||
title: "Issue", | ||
body: "This is a test issue", | ||
} | ||
); | ||
|
||
// add issue to project | ||
const item = await project.items.add(issue.node_id, { | ||
text: "text", | ||
number: "1", | ||
date: new Date("2020-02-02").toISOString(), | ||
singleSelect: "One", | ||
iteration: "Iteration 1", | ||
}); | ||
|
||
return [item.id]; | ||
} |
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,20 @@ | ||
// @ts-check | ||
|
||
import GitHubProject from "../../../index.js"; | ||
|
||
/** | ||
* @param {import("../../../").default} defaultTestProject | ||
* @param {string} [itemId] | ||
*/ | ||
export function test(defaultTestProject, itemId = "PVTI_1") { | ||
const project = new GitHubProject({ | ||
owner: defaultTestProject.owner, | ||
number: defaultTestProject.number, | ||
octokit: defaultTestProject.octokit, | ||
fields: { | ||
iteration: "Iteration", | ||
}, | ||
}); | ||
|
||
return project.items.update(itemId, { iteration: "Iteration 2" }); | ||
} |
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
Binary file not shown.