Skip to content

Commit 1ad3aa3

Browse files
use test.each()
1 parent 700346a commit 1ad3aa3

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

__tests__/util.test.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -94,27 +94,28 @@ test("getClubhouseWorkflowState", async () => {
9494
scope.done();
9595
});
9696

97-
test("getClubhouseStoryIdFromBranchName matching", () => {
98-
[["ch1", "1"],
99-
["ch89/something", "89"],
100-
["ch99-something", "99"],
101-
["prefix-1/ch123", "123"],
102-
["prefix-1-ch321", "321"],
103-
["prefix/ch5678/suffix", "5678"],
104-
["prefix-ch6789/suffix-more", "6789"],
105-
["prefix/ch7890-suffix", "7890"],
106-
["prefix-ch0987-suffix-extra", "0987"]].forEach(item => {
107-
const id = util.getClubhouseStoryIdFromBranchName(item[0]);
108-
expect(id).toEqual(item[1]);
109-
});
97+
test.each([
98+
["ch1", "1"],
99+
["ch89/something", "89"],
100+
["ch99-something", "99"],
101+
["prefix-1/ch123", "123"],
102+
["prefix-1-ch321", "321"],
103+
["prefix/ch5678/suffix", "5678"],
104+
["prefix-ch6789/suffix-more", "6789"],
105+
["prefix/ch7890-suffix", "7890"],
106+
["prefix-ch0987-suffix-extra", "0987"],
107+
])("getClubhouseStoryIdFromBranchName matches %s", (branch, expected) => {
108+
const id = util.getClubhouseStoryIdFromBranchName(branch);
109+
expect(id).toEqual(expected);
110110
});
111111

112-
test("getClubhouseStoryIdFromBranchName non-matching", () => {
113-
["prefix/ch8765+suffix", "ch554X", "ach8765", "this_ch1234"].forEach(branch => {
112+
test.each(["prefix/ch8765+suffix", "ch554X", "ach8765", "this_ch1234"])(
113+
"getClubhouseStoryIdFromBranchName does not match %s",
114+
(branch) => {
114115
const id = util.getClubhouseStoryIdFromBranchName(branch);
115116
expect(id).toBeNull();
116-
})
117-
});
117+
}
118+
);
118119

119120
test("getClubhouseURLFromPullRequest", async () => {
120121
const payload = {

0 commit comments

Comments
 (0)