Skip to content

Commit 2d76860

Browse files
committed
test(invalid-dependency): add unit tests
1 parent dad74c0 commit 2d76860

File tree

6 files changed

+27
-5
lines changed

6 files changed

+27
-5
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const base = require("../../jest.config.base.js");
2+
3+
module.exports = {
4+
...base,
5+
};
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
export const invalidFunction = (message: string) => () => {
2-
throw new Error(message);
3-
};
4-
5-
export const invalidAsyncFunction = (message: string) => () => Promise.reject(new Error(message));
1+
export * from "./invalidFunction";
2+
export * from "./invalidAsyncFunction";
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { invalidAsyncFunction } from "./invalidAsyncFunction";
2+
3+
describe("invalidAsyncFunction", () => {
4+
it("rejects with error containing message", async () => {
5+
const message = "Error";
6+
await expect(invalidAsyncFunction(message)).rejects.toThrow(new Error(message));
7+
});
8+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const invalidAsyncFunction = (message: string) => () => Promise.reject(new Error(message));
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { invalidFunction } from "./invalidFunction";
2+
3+
describe("invalidFunction", () => {
4+
it("throws error with message", () => {
5+
const message = "Error";
6+
expect(invalidFunction(message)).toThrowError(new Error(message));
7+
});
8+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const invalidFunction = (message: string) => () => {
2+
throw new Error(message);
3+
};

0 commit comments

Comments
 (0)