-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from bradgarropy/coverage
💯 coverage
- Loading branch information
Showing
9 changed files
with
166 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,10 @@ jobs: | |
run: npm install | ||
- name: "🧪 test" | ||
run: npm run test | ||
- name: "👖 coveralls" | ||
uses: coverallsapp/[email protected] | ||
env: | ||
github-token: ${{ secrets.COVERALLS_TOKEN }} | ||
- name: "🚀 publish" | ||
run: npm publish | ||
env: | ||
|
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 |
---|---|---|
|
@@ -4,5 +4,8 @@ | |
# dependencies | ||
node_modules | ||
|
||
# tests | ||
coverage | ||
|
||
# secrets | ||
.env* |
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 |
---|---|---|
|
@@ -12,6 +12,7 @@ node_modules | |
# build | ||
.github | ||
|
||
# test | ||
# tests | ||
src/tests | ||
jest.config.js | ||
coverage |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
const {getOctokit} = require("../../github/octokit") | ||
const {getLabels, deleteLabels, createLabels} = require("../../github/labels") | ||
|
||
jest.mock("../../github/octokit") | ||
|
||
describe("labels", () => { | ||
test("get", async () => { | ||
const expectedLabels = [ | ||
{name: "bug"}, | ||
{name: "enhance"}, | ||
{name: "todo"}, | ||
] | ||
|
||
getOctokit.mockImplementation(() => ({ | ||
issues: { | ||
listLabelsForRepo: () => { | ||
const labels = {data: expectedLabels} | ||
return labels | ||
}, | ||
}, | ||
})) | ||
|
||
const labels = await getLabels("bradgarropy/label-source") | ||
|
||
expect(labels).toEqual(expectedLabels) | ||
}) | ||
|
||
test("delete", async () => { | ||
getOctokit.mockImplementation(() => ({ | ||
issues: { | ||
deleteLabel: jest.fn(), | ||
}, | ||
})) | ||
|
||
const actual = await deleteLabels( | ||
["bug", "enhance", "todo"], | ||
"bradgarropy/label-destination", | ||
) | ||
|
||
expect(actual).toBeUndefined() | ||
}) | ||
|
||
test("create", async () => { | ||
getOctokit.mockImplementation(() => ({ | ||
issues: { | ||
createLabel: jest.fn(), | ||
}, | ||
})) | ||
|
||
const actual = await createLabels( | ||
["bug", "enhance", "todo"], | ||
"bradgarropy/label-destination", | ||
) | ||
|
||
expect(actual).toBeUndefined() | ||
}) | ||
|
||
test("label exists", async () => { | ||
getOctokit.mockImplementation(() => ({ | ||
issues: { | ||
createLabel: () => { | ||
throw "Label exists!" | ||
}, | ||
}, | ||
})) | ||
|
||
const actual = await createLabels( | ||
["bug", "enhance", "todo"], | ||
"bradgarropy/label-destination", | ||
) | ||
|
||
expect(actual).toBeUndefined() | ||
}) | ||
}) |
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,23 @@ | ||
const {createOctokit, getOctokit} = require("../../github") | ||
|
||
describe("octokit", () => { | ||
test("create", () => { | ||
const octokit = createOctokit("123456") | ||
|
||
const keys = Object.keys(octokit) | ||
|
||
expect(keys).toContainEqual("users") | ||
expect(keys).toContainEqual("repos") | ||
expect(keys).toContainEqual("issues") | ||
}) | ||
|
||
test("get", () => { | ||
const octokit = getOctokit() | ||
|
||
const keys = Object.keys(octokit) | ||
|
||
expect(keys).toContainEqual("users") | ||
expect(keys).toContainEqual("repos") | ||
expect(keys).toContainEqual("issues") | ||
}) | ||
}) |
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,54 @@ | ||
const {validToken, validRepo} = require("../../github/validate") | ||
const {createOctokit, getOctokit} = require("../../github/octokit") | ||
|
||
jest.mock("../../github/octokit") | ||
|
||
describe("validate", () => { | ||
test("valid token", async () => { | ||
createOctokit.mockImplementation(() => ({ | ||
users: { | ||
getAuthenticated: () => true, | ||
}, | ||
})) | ||
|
||
const isValidToken = await validToken("123456") | ||
expect(isValidToken).toBeTruthy() | ||
}) | ||
|
||
test("invalid token", async () => { | ||
createOctokit.mockImplementation(() => ({ | ||
users: { | ||
getAuthenticated: () => { | ||
throw "Invalid token!" | ||
}, | ||
}, | ||
})) | ||
|
||
const isValidToken = await validToken("123456") | ||
expect(isValidToken).not.toBeTruthy() | ||
}) | ||
|
||
test("valid repo", async () => { | ||
getOctokit.mockImplementation(() => ({ | ||
repos: { | ||
get: () => true, | ||
}, | ||
})) | ||
|
||
const isValidRepo = await validRepo("bradgarropy/labman-cli") | ||
expect(isValidRepo).toBeTruthy() | ||
}) | ||
|
||
test("invalid repo", async () => { | ||
getOctokit.mockImplementation(() => ({ | ||
repos: { | ||
get: () => { | ||
throw "Invalid token!" | ||
}, | ||
}, | ||
})) | ||
|
||
const isValidRepo = await validRepo("bradgarropy/invalid-repo") | ||
expect(isValidRepo).not.toBeTruthy() | ||
}) | ||
}) |