Skip to content

Commit

Permalink
tests: add case normalizer to cover sandbox.
Browse files Browse the repository at this point in the history
  • Loading branch information
narekhovhannisyan committed Dec 1, 2023
1 parent c71bc69 commit 36eeffc
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/__tests__/lib/normalizer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,43 @@ describe("lib/normalizer: ", () => {
// @ts-ignore
cb(null, mailData);
});

it("checks if testing client is switched.", () => {
expect.assertions(3);

const mockResponse = {
statusCode: 200,
};
const mockClient = {
testing: {
send: jest.fn(() => Promise.resolve(mockResponse)),
},
};

const callback = (error: Error, data: SendError) => {
expect(error).toBeNull();
expect(data).toEqual(mockResponse);
};
const mailData = {
sandbox: true,
text: "mock-text",
to: {
address: "mock@mail.com",
name: "mock-name",
},
from: {
address: "mock@mail.com",
name: "mock-name",
},
subject: "mock-subject",
};

// @ts-ignore
const cb = normalizeCallback(mockClient, callback);

// @ts-ignore
cb(null, mailData);
expect(mockClient.testing.send).toBeCalledTimes(1);
});
});
});

0 comments on commit 36eeffc

Please sign in to comment.