Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
singingwolfboy committed May 8, 2020
1 parent a7c56af commit 4189874
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 30 additions & 0 deletions __tests__/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,36 @@ test("getClubhouseProjectByName", async () => {
scope.done();
});

test("getClubhouseWorkflowState", async () => {
const scope = nock("https://api.clubhouse.io")
.get("/api/v3/teams/123")
.query(true)
.reply(200, {
id: 123,
name: "fake-team",
workflow: {
name: "fake-workflow",
states: [
{ name: "Plan", type: "unstarted" },
{ name: "Execute", type: "started" },
{ name: "Finished", type: "done" },
{ name: "Aborted", type: "done" },
],
},
});

const http = new HttpClient();
const project = { name: "fake-team", team_id: 123 };
const workflowState = await util.getClubhouseWorkflowState(
"Finished",
http,
project as any
);
expect(workflowState).toEqual({ name: "Finished", type: "done" });

scope.done();
});

test("getClubhouseURLFromPullRequest", async () => {
const payload = {
pull_request: {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5247,7 +5247,7 @@ function getClubhouseWorkflowState(stateName, http, project) {
});
const teamId = project.team_id;
try {
const teamResponse = yield http.getJson(`https://api.clubhouse.io/api/v3/team/${teamId}?token=${CLUBHOUSE_TOKEN}`);
const teamResponse = yield http.getJson(`https://api.clubhouse.io/api/v3/teams/${teamId}?token=${CLUBHOUSE_TOKEN}`);
const team = teamResponse.result;
if (!team) {
core.setFailed(`HTTP ${teamResponse.statusCode} https://api.clubhouse.io/api/v3/teams/${teamId}`);
Expand Down

0 comments on commit 4189874

Please sign in to comment.