Skip to content

Commit 0c3ed5a

Browse files
committed
Added scope check for LK id
1 parent 7bbdb4b commit 0c3ed5a

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

specs/workflows/dev.spec.js

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
1-
const resetWorkflow = require("../../src/workflows/dev");
2-
const run = require("../../src/workflows/steps");
3-
41
describe("dev workflow", () => {
5-
it("should have all of the required steps", () => {
6-
expect(resetWorkflow).toEqual([
7-
run.fetchUpstream,
8-
run.gitCreateBranchOrigin,
9-
run.checkoutBaseBranch,
10-
run.rebaseUpstreamBaseBranch,
11-
run.checkoutWorkingBranch,
12-
run.gitCreateBranchUpstream,
13-
run.githubUpstream,
14-
run.githubOrigin,
15-
run.updatePullRequestTitle,
16-
run.addLKId,
17-
run.updatePullRequestBody,
18-
run.createGithubPullRequestAganistBranch
19-
]);
2+
let resetWorkflow;
3+
describe("has LK scope", () => {
4+
beforeEach(() => {
5+
jest.resetModules();
6+
jest.doMock("../../src/utils", () => ({
7+
hasLkScope: jest.fn(() => true)
8+
}));
9+
10+
resetWorkflow = require("../../src/workflows/dev");
11+
});
12+
13+
it("should have all of the required steps", () => {
14+
expect(resetWorkflow.length).toEqual(12);
15+
});
16+
});
17+
18+
describe("doesn't have LK scope", () => {
19+
beforeEach(() => {
20+
jest.resetModules();
21+
jest.doMock("../../src/utils", () => ({
22+
hasLkScope: jest.fn(() => false)
23+
}));
24+
25+
resetWorkflow = require("../../src/workflows/dev");
26+
});
27+
28+
it("should have all of the required steps", () => {
29+
expect(resetWorkflow.length).toEqual(11);
30+
});
2031
});
2132
});

src/workflows/dev.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const run = require("./steps/index");
2+
const { hasLkScope } = require("../utils");
23

34
module.exports = [
45
run.fetchUpstream,
@@ -10,7 +11,7 @@ module.exports = [
1011
run.githubUpstream,
1112
run.githubOrigin,
1213
run.updatePullRequestTitle,
13-
run.addLKId,
14+
hasLkScope() ? run.addLKId : null,
1415
run.updatePullRequestBody,
1516
run.createGithubPullRequestAganistBranch
16-
];
17+
].filter(x => x);

0 commit comments

Comments
 (0)