Skip to content

Commit

Permalink
Real tests, real features
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Oct 1, 2016
1 parent 6edab09 commit f290d78
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
6 changes: 2 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"flowtype",
"flow-vars"
],
"presets": ["es2015", "react"],
"presets": ["es2015"],
"rules": {
"quotes": [1, "double", "avoid-escape"],
"flowtype/define-flow-type": 1,
Expand All @@ -24,9 +24,7 @@
"flowtype/valid-syntax": 1
},
"ignore": [
"**/*.test.js",
"distribution",
"**/_tests/"
"distribution"
],
"settings": {
"flowtype": {
Expand Down
37 changes: 36 additions & 1 deletion source/ci_source/_tests/_travis.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,44 @@ let correctEnv = {
"TRAVIS_REPO_SLUG": "artsy/eigen"
}

describe(".validates_as_ci?", () => {
describe(".isCI", () => {
test("validates when all Travis environment vars are set and Josh K says so", () => {
let travis = new Travis(correctEnv)
expect(travis.isCI).toBeTruthy()
})
test("does not validate without josh", () => {
let travis = new Travis({})
expect(travis.isCI).toBeFalsy()
})
})

describe(".isPR", () => {
test("validates when all Travis environment vars are set and Josh K says so", () => {
let travis = new Travis(correctEnv)
expect(travis.isPR).toBeTruthy()
})

test("does not validate without josh", () => {
let travis = new Travis({})
expect(travis.isPR).toBeFalsy()
})

let envs = ["TRAVIS_PULL_REQUEST", "TRAVIS_REPO_SLUG"]
envs.forEach((key: string) => {
var env = {
"HAS_JOSH_K_SEAL_OF_APPROVAL": "true",
"TRAVIS_PULL_REQUEST": "800",
"TRAVIS_REPO_SLUG": "artsy/eigen"
}
env[key] = null

test(`does not validate when ${key} is missing`, () => {
let travis = new Travis({})
expect(travis.isPR).toBeFalsy()
})
})

xit("needs to have a PR number", () => {

})
})
9 changes: 8 additions & 1 deletion source/ci_source/travis.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ export default class Travis {
}

get isPR () : boolean {
return this.env.HAS_JOSH_K_SEAL_OF_APPROVAL != null
let mustHave = ["TRAVIS_PULL_REQUEST", "TRAVIS_REPO_SLUG"]
// TODO: has valid int for TRAVIS_PULL_REQUEST
let hasKey = mustHave.map((key: string) : boolean => {
return this.env.hasOwnProperty(key) && this.env[key].length > 0
})

let gotRequiredKeys = !hasKey.includes(false)
return gotRequiredKeys
}
}

0 comments on commit f290d78

Please sign in to comment.