Skip to content

Commit 1ccd5da

Browse files
committed
chore: Add tests for workflow
1 parent e09221a commit 1ccd5da

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

lib/package/workflow.spec.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { describe, expect, test } from "bun:test";
2+
import { Job } from "./job";
23
import { Workflow } from "./workflow";
34

45
describe("Workflow", () => {
@@ -14,6 +15,34 @@ describe("Workflow", () => {
1415
});
1516
});
1617

18+
test("workflow with run-name", () => {
19+
const workflow = new Workflow("simple", {
20+
runName: "Simple Workflow",
21+
on: "push",
22+
});
23+
24+
expect(workflow.toJSON()).toEqual({
25+
name: "simple",
26+
"run-name": "Simple Workflow",
27+
on: "push",
28+
jobs: {},
29+
});
30+
});
31+
32+
test("workflow with permissions", () => {
33+
const workflow = new Workflow("simple", {
34+
on: "push",
35+
permissions: { contents: "read" },
36+
});
37+
38+
expect(workflow.toJSON()).toEqual({
39+
name: "simple",
40+
on: "push",
41+
permissions: { contents: "read" },
42+
jobs: {},
43+
});
44+
});
45+
1746
test("workflow with env", () => {
1847
const workflow = new Workflow("simple", {
1948
on: "push",
@@ -33,4 +62,47 @@ describe("Workflow", () => {
3362
jobs: {},
3463
});
3564
});
65+
66+
test("workflow with concurrency", () => {
67+
const workflow = new Workflow("simple", {
68+
on: "push",
69+
concurrency: {
70+
group: "group",
71+
cancelInProgress: true,
72+
},
73+
});
74+
75+
expect(workflow.toJSON()).toEqual({
76+
name: "simple",
77+
on: "push",
78+
concurrency: {
79+
group: "group",
80+
"cancel-in-progress": true,
81+
},
82+
jobs: {},
83+
});
84+
});
85+
86+
test("workflow with jobs", () => {
87+
const workflow = new Workflow("simple", {
88+
on: "push",
89+
});
90+
91+
workflow.addJob(
92+
new Job("test", {
93+
runsOn: "ubuntu-latest",
94+
}).run("echo 'Hello, world!'"),
95+
);
96+
97+
expect(workflow.toJSON()).toEqual({
98+
name: "simple",
99+
on: "push",
100+
jobs: {
101+
test: {
102+
"runs-on": "ubuntu-latest",
103+
steps: [{ run: "echo 'Hello, world!'" }],
104+
},
105+
},
106+
});
107+
});
36108
});

0 commit comments

Comments
 (0)