Skip to content

Commit

Permalink
Merge 97a4171 into 23af92c
Browse files Browse the repository at this point in the history
  • Loading branch information
bobvanderlinden committed Aug 25, 2018
2 parents 23af92c + 97a4171 commit 87b782b
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 110 deletions.
18 changes: 9 additions & 9 deletions test/conditions/blockingChecks.test.ts
@@ -1,10 +1,10 @@
import blockingChecks from '../../src/conditions/blockingChecks'
import { createHandlerContext, createPullRequestInfo, successCheckRun, failedCheckRun } from '../mock'
import { createConditionConfig, createPullRequestInfo, successCheckRun, failedCheckRun } from '../mock'

describe('blockingChecks', () => {
it('returns success pull request has succeeding check', async () => {
const result = blockingChecks(
createHandlerContext(),
createConditionConfig(),
createPullRequestInfo({
checkRuns: [successCheckRun]
})
Expand All @@ -14,7 +14,7 @@ describe('blockingChecks', () => {

it('returns pending pull request has in_progress check', async () => {
const result = blockingChecks(
createHandlerContext(),
createConditionConfig(),
createPullRequestInfo({
checkRuns: [{
...successCheckRun,
Expand All @@ -27,7 +27,7 @@ describe('blockingChecks', () => {

it('returns pending pull request has queued check', async () => {
const result = blockingChecks(
createHandlerContext(),
createConditionConfig(),
createPullRequestInfo({
checkRuns: [{
...successCheckRun,
Expand All @@ -40,7 +40,7 @@ describe('blockingChecks', () => {

it('returns fail pull request has failed check', async () => {
const result = blockingChecks(
createHandlerContext(),
createConditionConfig(),
createPullRequestInfo({
checkRuns: [failedCheckRun]
})
Expand All @@ -50,7 +50,7 @@ describe('blockingChecks', () => {

it('returns fail pull request has timed_out check', async () => {
const result = blockingChecks(
createHandlerContext(),
createConditionConfig(),
createPullRequestInfo({
checkRuns: [{
...failedCheckRun,
Expand All @@ -63,7 +63,7 @@ describe('blockingChecks', () => {

it('returns fail pull request has cancelled check', async () => {
const result = blockingChecks(
createHandlerContext(),
createConditionConfig(),
createPullRequestInfo({
checkRuns: [{
...failedCheckRun,
Expand All @@ -76,7 +76,7 @@ describe('blockingChecks', () => {

it('returns fail pull request has action_required check', async () => {
const result = blockingChecks(
createHandlerContext(),
createConditionConfig(),
createPullRequestInfo({
checkRuns: [{
...failedCheckRun,
Expand All @@ -89,7 +89,7 @@ describe('blockingChecks', () => {

it('returns success pull request has neutral check', async () => {
const result = blockingChecks(
createHandlerContext(),
createConditionConfig(),
createPullRequestInfo({
checkRuns: [{
...failedCheckRun,
Expand Down
24 changes: 8 additions & 16 deletions test/conditions/blockingLabels.test.ts
@@ -1,12 +1,10 @@
import blockingLabels from '../../src/conditions/blockingLabels'
import { createHandlerContext, createPullRequestInfo, createConfig } from '../mock'
import { createPullRequestInfo, createConditionConfig } from '../mock'

describe('blockingLabels', () => {
it('returns success with no labels and no configuration', async () => {
const result = blockingLabels(
createHandlerContext({
config: createConfig()
}),
createConditionConfig(),
createPullRequestInfo({
labels: {
nodes: []
Expand All @@ -18,10 +16,8 @@ describe('blockingLabels', () => {

it('returns success with label not in configuration', async () => {
const result = blockingLabels(
createHandlerContext({
config: createConfig({
blockingLabels: ['blocking label']
})
createConditionConfig({
blockingLabels: ['blocking label']
}),
createPullRequestInfo({
labels: {
Expand All @@ -36,10 +32,8 @@ describe('blockingLabels', () => {

it('returns fail with label in configuration', async () => {
const result = blockingLabels(
createHandlerContext({
config: createConfig({
blockingLabels: ['blocking label']
})
createConditionConfig({
blockingLabels: ['blocking label']
}),
createPullRequestInfo({
labels: {
Expand All @@ -54,10 +48,8 @@ describe('blockingLabels', () => {

it('returns fail with label, among others, in configuration', async () => {
const result = blockingLabels(
createHandlerContext({
config: createConfig({
blockingLabels: ['blocking label']
})
createConditionConfig({
blockingLabels: ['blocking label']
}),
createPullRequestInfo({
labels: {
Expand Down
36 changes: 14 additions & 22 deletions test/conditions/maximumChangesRequested.test.ts
@@ -1,12 +1,10 @@
import doesNotHaveMaximumChangesRequested from '../../src/conditions/maximumChangesRequested'
import { createHandlerContext, createConfig, createPullRequestInfo, approvedReview, changesRequestedReview } from '../mock'
import { createConditionConfig, createPullRequestInfo, approvedReview, changesRequestedReview } from '../mock'

describe('maximumChangesRequested', () => {
it('returns success when owner approved and nothing was configured', async () => {
const result = doesNotHaveMaximumChangesRequested(
createHandlerContext({
config: createConfig()
}),
createConditionConfig(),
createPullRequestInfo({
reviews: {
nodes: [
Expand All @@ -20,12 +18,10 @@ describe('maximumChangesRequested', () => {

it('returns fail when owner requested changes and none role has 0 maximum requested changes', async () => {
const result = doesNotHaveMaximumChangesRequested(
createHandlerContext({
config: createConfig({
maxRequestedChanges: {
NONE: 0
}
})
createConditionConfig({
maxRequestedChanges: {
NONE: 0
}
}),
createPullRequestInfo({
reviews: {
Expand All @@ -40,12 +36,10 @@ describe('maximumChangesRequested', () => {

it('returns fail when owner requested changes and owner role has 0 maximum requested changes', async () => {
const result = doesNotHaveMaximumChangesRequested(
createHandlerContext({
config: createConfig({
maxRequestedChanges: {
OWNER: 0
}
})
createConditionConfig({
maxRequestedChanges: {
OWNER: 0
}
}),
createPullRequestInfo({
reviews: {
Expand All @@ -60,12 +54,10 @@ describe('maximumChangesRequested', () => {

it('returns success when member requested changes but owner role has 0 maximum requested changes', async () => {
const result = doesNotHaveMaximumChangesRequested(
createHandlerContext({
config: createConfig({
maxRequestedChanges: {
OWNER: 0
}
})
createConditionConfig({
maxRequestedChanges: {
OWNER: 0
}
}),
createPullRequestInfo({
reviews: {
Expand Down
8 changes: 4 additions & 4 deletions test/conditions/mergeable.test.ts
@@ -1,10 +1,10 @@
import mergeable from '../../src/conditions/mergeable'
import { createHandlerContext, createPullRequestInfo } from '../mock'
import { createConditionConfig, createPullRequestInfo } from '../mock'

describe('mergeable', () => {
it('returns success pull request state is MERGEABLE', async () => {
const result = mergeable(
createHandlerContext(),
createConditionConfig(),
createPullRequestInfo({
mergeable: 'MERGEABLE'
})
Expand All @@ -14,7 +14,7 @@ describe('mergeable', () => {

it('returns fail pull request state is CONFLICTING', async () => {
const result = mergeable(
createHandlerContext(),
createConditionConfig(),
createPullRequestInfo({
mergeable: 'CONFLICTING'
})
Expand All @@ -24,7 +24,7 @@ describe('mergeable', () => {

it('returns fail pull request state is UNKNOWN', async () => {
const result = mergeable(
createHandlerContext(),
createConditionConfig(),
createPullRequestInfo({
mergeable: 'UNKNOWN'
})
Expand Down
46 changes: 18 additions & 28 deletions test/conditions/minimumApprovals.test.ts
@@ -1,15 +1,13 @@
import hasMinimumApprovals from '../../src/conditions/minimumApprovals'
import { createHandlerContext, createConfig, createPullRequestInfo, approvedReview } from '../mock'
import { createConditionConfig, createPullRequestInfo, approvedReview } from '../mock'

describe('minimumApprovals', () => {
it('returns success when owner approved and owner was configured', async () => {
const result = hasMinimumApprovals(
createHandlerContext({
config: createConfig({
minApprovals: {
OWNER: 1
}
})
createConditionConfig({
minApprovals: {
OWNER: 1
}
}),
createPullRequestInfo({
reviews: {
Expand All @@ -24,12 +22,10 @@ describe('minimumApprovals', () => {

it('returns fail when member approved but owner was configured', async () => {
const result = hasMinimumApprovals(
createHandlerContext({
config: createConfig({
minApprovals: {
OWNER: 1
}
})
createConditionConfig({
minApprovals: {
OWNER: 1
}
}),
createPullRequestInfo({
reviews: {
Expand All @@ -44,12 +40,10 @@ describe('minimumApprovals', () => {

it('returns success when owner approved and member was configured', async () => {
const result = hasMinimumApprovals(
createHandlerContext({
config: createConfig({
minApprovals: {
MEMBER: 1
}
})
createConditionConfig({
minApprovals: {
MEMBER: 1
}
}),
createPullRequestInfo({
reviews: {
Expand All @@ -64,9 +58,7 @@ describe('minimumApprovals', () => {

it('returns success when owner approved but nothing was configured', async () => {
const result = hasMinimumApprovals(
createHandlerContext({
config: createConfig()
}),
createConditionConfig(),
createPullRequestInfo({
reviews: {
nodes: [
Expand All @@ -80,12 +72,10 @@ describe('minimumApprovals', () => {

it('returns fail when no-one approved but member was configured', async () => {
const result = hasMinimumApprovals(
createHandlerContext({
config: createConfig({
minApprovals: {
MEMBER: 1
}
})
createConditionConfig({
minApprovals: {
MEMBER: 1
}
}),
createPullRequestInfo({
reviews: {
Expand Down
6 changes: 3 additions & 3 deletions test/conditions/open.test.ts
@@ -1,10 +1,10 @@
import open from '../../src/conditions/open'
import { createHandlerContext, createPullRequestInfo } from '../mock'
import { createPullRequestInfo, createConditionConfig } from '../mock'

describe('open', () => {
it('returns success pull request state is open', async () => {
const result = open(
createHandlerContext(),
createConditionConfig(),
createPullRequestInfo({
state: 'OPEN'
})
Expand All @@ -17,7 +17,7 @@ describe('open', () => {
'MERGED'
])('returns fail pull request state is not %s', async (state) => {
const result = open(
createHandlerContext(),
createConditionConfig(),
createPullRequestInfo({
state
})
Expand Down

0 comments on commit 87b782b

Please sign in to comment.