Skip to content

Commit

Permalink
Updates Jest, and ts-jest - you never know
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Aug 5, 2017
1 parent 25d0d11 commit 1f4d82e
Show file tree
Hide file tree
Showing 4 changed files with 330 additions and 91 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ matrix:

script:
- yarn lint
- yarn add jest
- yarn jest
- yarn docs
- if [[ $TRAVIS_NODE_VERSION == "8" ]]; then yarn add dtslint; yarn dts-lint; fi
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@
"date-fns": "^1.28.3",
"husky": "^0.14.0",
"in-publish": "^2.0.0",
"jest": "^20.0.0",
"jest": "^20.0.4",
"lint-staged": "^4.0.0",
"madge": "^2.0.0",
"prettier": "^1.5.3",
"shx": "^0.2.1",
"ts-jest": "^20.0.0",
"ts-jest": "^20.0.9",
"ts-node": "^3.2.1",
"tslint": "^5.3.0",
"tslint-config-prettier": "^1.0.0",
Expand Down
70 changes: 35 additions & 35 deletions source/platforms/_tests/_github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,43 @@ const fixtures = resolve(__dirname, "fixtures")
export const requestWithFixturedJSON = async (path: string): Promise<() => Promise<any>> => () =>
Promise.resolve(JSON.parse(readFileSync(`${fixtures}/${path}`, {}).toString()))

// Mock GitHubAPI class
jest.mock("../github/GitHubAPI", () => {
class GitHubAPI {
async getPullRequestInfo() {
const fixtures = await requestWithFixturedJSON("github_pr.json")
return await fixtures()
}
async getIssue() {
const fixtures = await requestWithFixturedJSON("github_issue.json")
return await fixtures()
}

async getPullRequestCommits() {
const fixtures = await requestWithFixturedJSON("github_commits.json")
return await fixtures()
}

async getReviews() {
const fixtures = await requestWithFixturedJSON("reviews.json")
return await fixtures()
}

async getReviewerRequests() {
const fixtures = await requestWithFixturedJSON("requested_reviewers.json")
return await fixtures()
}

getExternalAPI() {
return {}
}

APIMetadataForPR() {
return {}
}
class mockGitHubAPI /*tslint:disable-line*/ {
async getPullRequestInfo() {
const fixtures = await requestWithFixturedJSON("github_pr.json")
return await fixtures()
}
async getIssue() {
const fixtures = await requestWithFixturedJSON("github_issue.json")
return await fixtures()
}

async getPullRequestCommits() {
const fixtures = await requestWithFixturedJSON("github_commits.json")
return await fixtures()
}

async getReviews() {
const fixtures = await requestWithFixturedJSON("reviews.json")
return await fixtures()
}

return { GitHubAPI }
async getReviewerRequests() {
const fixtures = await requestWithFixturedJSON("requested_reviewers.json")
return await fixtures()
}

getExternalAPI() {
return {}
}

APIMetadataForPR() {
return {}
}
}

// Mock GitHubAPI class
jest.mock("../github/GitHubAPI", () => {
return { GitHubAPI: mockGitHubAPI }
})

import { GitHub } from "../GitHub"
Expand Down

0 comments on commit 1f4d82e

Please sign in to comment.