Skip to content

Commit

Permalink
Fix github actions check
Browse files Browse the repository at this point in the history
  • Loading branch information
f-meloni committed Nov 5, 2019
1 parent 6bbe565 commit 13297ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions source/ci_source/providers/GitHubActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class GitHubActions implements CISource {
}

get useEventDSL() {
return this.event.pull_request !== undefined || this.event.issue !== undefined
return this.event.pull_request === undefined && this.event.issue === undefined
}

get pullRequestID(): string {
Expand All @@ -179,8 +179,8 @@ export class GitHubActions implements CISource {
get repoSlug(): string {
if (this.event.pull_request !== undefined) {
return this.event.pull_request.base.repo.full_name
} else if (this.event.repo !== undefined) {
return this.event.repo.full_name
} else if (this.event.repository !== undefined) {
return this.event.repository.full_name
}

throw new Error("repoSlug was called on GitHubActions when it wasn't a PR")
Expand Down
14 changes: 7 additions & 7 deletions source/ci_source/providers/_tests/_gitHubActions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ const issueEvent = {
issue: {
number: "2",
},
repo: {
repository: {
full_name: "danger/danger-js",
},
}

describe("use event DSL", () => {
it("returns true when event.json contains pull_request data", () => {
it("returns false when event.json contains pull_request data", () => {
const ci = new GitHubActions({}, pullRequestEvent)
expect(ci.useEventDSL).toBeTruthy()
expect(ci.useEventDSL).toBeFalsy()
})

it("returns true when event.json contains issue data", () => {
it("returns false when event.json contains issue data", () => {
const ci = new GitHubActions({}, issueEvent)
expect(ci.useEventDSL).toBeTruthy()
expect(ci.useEventDSL).toBeFalsy()
})

it("returns false when event.json doesn't contain issue or pull_request data", () => {
it("returns true when event.json doesn't contain issue or pull_request data", () => {
const ci = new GitHubActions({}, {})
expect(ci.useEventDSL).toBeFalsy()
expect(ci.useEventDSL).toBeTruthy()
})
})

Expand Down

0 comments on commit 13297ba

Please sign in to comment.