Skip to content

Commit

Permalink
Clear mocked danger run between tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cysp committed Dec 27, 2018
1 parent 460708f commit 67396e9
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions source/commands/ci/_tests/runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const defaultAppArgs: Partial<SharedCLI> = {
const source = new FakeCI({})
const platform = new FakePlatform()

beforeEach(() => {
mockRunDangerSubprocess.mockReset()
})

it("uses the source and platform from config", async () => {
await runRunner(defaultAppArgs as SharedCLI, { platform, source })

Expand All @@ -25,6 +29,44 @@ it("uses the source and platform from config", async () => {
expect(executor.platform).toEqual(platform)
})

it("does not use GitHub Checks by default", async () => {
await runRunner(defaultAppArgs as SharedCLI, { platform, source })

// Pull the executor out of the call to runDangerSubprocess
const executor: Executor = mockRunDangerSubprocess.mock.calls[0][2]
expect(executor.ciSource).toEqual(source)
expect(executor.platform).toEqual(platform)
expect(executor.options.disableGitHubChecksSupport).toEqual(true)
})

it("uses GitHub Checks if requested", async () => {
const customArgs = {
...defaultAppArgs,
useGithubChecks: true,
} as SharedCLI
await runRunner(customArgs, { platform, source })

// Pull the executor out of the call to runDangerSubprocess
const executor: Executor = mockRunDangerSubprocess.mock.calls[0][2]
expect(executor.ciSource).toEqual(source)
expect(executor.platform).toEqual(platform)
expect(executor.options.disableGitHubChecksSupport).toEqual(false)
})

it("does not use GitHub Checks if requested not to", async () => {
const customArgs = {
...defaultAppArgs,
useGithubChecks: false,
} as SharedCLI
await runRunner(customArgs, { platform, source })

// Pull the executor out of the call to runDangerSubprocess
const executor: Executor = mockRunDangerSubprocess.mock.calls[0][2]
expect(executor.ciSource).toEqual(source)
expect(executor.platform).toEqual(platform)
expect(executor.options.disableGitHubChecksSupport).toEqual(true)
})

// TODO: This occasionally fails!
it.skip("passes the dangerID from args into the executor config", async () => {
const customArgs = {
Expand Down

0 comments on commit 67396e9

Please sign in to comment.