Skip to content

Commit af0bd1c

Browse files
committed
add tests
1 parent 0dd5541 commit af0bd1c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/index.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,34 @@ describe("measure", () => {
7474
expect(count).toBe(100);
7575
});
7676

77+
it("provides result of beforeEach to function", async () => {
78+
await measure((value) => {
79+
if (value !== 1) {
80+
throw new Error("error");
81+
}
82+
}, {
83+
beforeEach: () => 1
84+
});
85+
});
86+
7787
it("supports an afterEach callback", async () => {
7888
let count = 0;
7989
await measure(() => { }, { afterEach: () => count++ });
8090
expect(count).toBe(100);
8191
});
92+
93+
it("provides result of beforeEach and function to afterEach", async () => {
94+
await measure(() => {
95+
return 2;
96+
}, {
97+
beforeEach: () => 1,
98+
afterEach: (beforeValue, functionValue) => {
99+
if (beforeValue !== 1 || functionValue !== 2) {
100+
throw new Error("error");
101+
}
102+
}
103+
});
104+
});
82105
});
83106

84107
describe("Measurement", () => {

0 commit comments

Comments
 (0)