Skip to content

Commit

Permalink
test(ci_source): add initial test case for external ci source lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Dec 31, 2016
1 parent 95cd6d6 commit 27777ab
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
15 changes: 14 additions & 1 deletion source/ci_source/_tests/_ci_sourse.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// @flow

import Fake from "../providers/Fake"
import { getCISourceForEnv } from "../ci_source"
import DummyCI from "./fixtures/dummy_ci"
import { getCISourceForEnv, getCISourceForExternal } from "../ci_source"

describe(".getCISourceForEnv", () => {
test("returns undefined if nothing is found", () => {
Expand All @@ -14,3 +15,15 @@ describe(".getCISourceForEnv", () => {
expect(ci).toBeInstanceOf(Fake)
})
})

describe(".getCISourceForExternal", () => {
test("should resolve module relatively", () => {
const ci = getCISourceForExternal({ }, "./source/ci_source/_tests/fixtures/dummy_ci.js")
expect(ci).toBeInstanceOf(DummyCI)
})

test("should return undefined if module resolution fails", () => {
const ci = getCISourceForExternal({ }, "./dummy_ci.js")
expect(ci).toBeUndefined()
})
})
13 changes: 13 additions & 0 deletions source/ci_source/_tests/fixtures/dummy_ci.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @flow
"use strict"

export default class DummyCI {
get name(): string { return "Dummy Testing CI" }

get isCI(): boolean { return false }
get isPR(): boolean { return true }

get pullRequestID(): string { return this.env.pr }
get repoSlug(): string { return this.env.repo }
get supportedPlatforms(): string[] { return ["github"] }
}

0 comments on commit 27777ab

Please sign in to comment.