generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: baseBranch wrong field accessed (#154)
* chore: test basebranch pr * fix: baseBranch wrong field accessed * add more test * fix warnings * fix tests
- Loading branch information
Showing
6 changed files
with
86 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import match from "../../src/matcher/base-branch"; | ||
import * as github from "@actions/github"; | ||
import { Config } from "../../src/config"; | ||
|
||
function getMatchedLabels(config: Config): string[] { | ||
// @ts-ignore | ||
return match(null, config); | ||
} | ||
|
||
const config: Config = { | ||
version: "v1", | ||
labels: [ | ||
{ | ||
label: "release", | ||
matcher: { | ||
baseBranch: "^release/.*" | ||
} | ||
}, | ||
{ | ||
label: "master", | ||
matcher: { | ||
baseBranch: "master" | ||
} | ||
} | ||
] | ||
}; | ||
|
||
describe("empty", function() { | ||
it("no payload should be undefined", async function() { | ||
github.context.payload = {}; | ||
expect(getMatchedLabels(config)).toEqual([]); | ||
}); | ||
|
||
it("pull_request should be empty", async function() { | ||
github.context.payload = { | ||
pull_request: { | ||
number: 1, | ||
title: "nothing interesting", | ||
base: { | ||
ref: "main" | ||
} | ||
} | ||
}; | ||
|
||
expect(getMatchedLabels(config)).toEqual([]); | ||
}); | ||
}); | ||
|
||
describe("pull_request", () => { | ||
it("should have release", async function() { | ||
github.context.payload = { | ||
pull_request: { | ||
number: 1, | ||
title: "spaceship", | ||
base: { | ||
ref: "release/1.0" | ||
} | ||
} | ||
}; | ||
|
||
const labels = getMatchedLabels(config); | ||
expect(labels).toEqual(["release"]); | ||
}); | ||
|
||
it("should have main", async function() { | ||
github.context.payload = { | ||
pull_request: { | ||
number: 1, | ||
title: "spaceship", | ||
base: { | ||
ref: "master" | ||
} | ||
} | ||
}; | ||
|
||
const labels = getMatchedLabels(config); | ||
expect(labels).toEqual(["master"]); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters