Skip to content

Commit

Permalink
Add some test structure for the github class
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Oct 30, 2016
1 parent 8cc6e49 commit 8aaac18
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

// Add your own contribution below

* Started turning this into a real project by adding tests - orta

### 0.0.5-0.0.10

* Changes some files casing, added some logs, a bit of error reporting, and verifying everything works through npm - orta
Expand Down
26 changes: 26 additions & 0 deletions source/platforms/_tests/GitHub.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// @flow

import { GitHub } from "../GitHub"
import Fake from "../../ci_source/Fake"

/** Gets a mocked out GitHub class for checking a get path */
const mockGitHubWithGetForPath = (expectedPath): GitHub => {
const mockSource = new Fake({})
const github = new GitHub("Token", mockSource)

github.get = (path: string, headers: any = {}, body: any = {}, method: string = "GET"): Promise<any> => {
return new Promise((resolve: any, reject: any) => {
expect(path).toBe(expectedPath)
resolve({})
})
}

return github
}

it("sets the correct paths for pull request comments", () => {
const expectedPath = "repos/artsy/emission/issues/327/comments"
const github = mockGitHubWithGetForPath(expectedPath)
expect(github.getPullRequestComments())
})

0 comments on commit 8aaac18

Please sign in to comment.