Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zoe-codez committed Nov 11, 2024
1 parent 98b3aac commit dcda8a9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion testing/internal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,33 @@ describe("Fetch Extension", () => {

describe("removeFn", () => {
const internal = new InternalDefinition();
const mockRemove: () => TBlackHole = jest.fn(() => ({}) as TBlackHole);

it("should return a function with a remove property", () => {
const mockRemove: () => TBlackHole = jest.fn(() => ({}) as TBlackHole);
const result = internal.removeFn(mockRemove);

expect(typeof result).toBe("function");
expect(result.remove).toBe(mockRemove);
});

it("should correctly call the remove function", () => {
const mockRemove: () => TBlackHole = jest.fn(() => ({}) as TBlackHole);
const result = internal.removeFn(mockRemove);

result(); // Call the function
expect(mockRemove).toHaveBeenCalledTimes(1);
});

it("should allow calling remove via the returned function", () => {
const mockRemove: () => TBlackHole = jest.fn(() => ({}) as TBlackHole);
const result = internal.removeFn(mockRemove);

result.remove!(); // Call remove
expect(mockRemove).toHaveBeenCalledTimes(1);
});

it("should support both destructured and non-destructured usage", () => {
const mockRemove: () => TBlackHole = jest.fn(() => ({}) as TBlackHole);
// Destructured case
const { remove } = internal.removeFn(mockRemove);
remove!(); // Call remove
Expand Down

0 comments on commit dcda8a9

Please sign in to comment.