Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: adjust 'packages/mail/src/mail.d.ts' #1320

Merged
merged 4 commits into from Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/mail/src/mail.d.ts
Expand Up @@ -32,12 +32,12 @@ declare class MailService {
/**
* Send email
*/
send(data: MailDataRequired | MailDataRequired[], isMultiple?: boolean, cb?: (err: Error | ResponseError, result: [ClientResponse, {}]) => void): Promise<[ClientResponse, {}]>;
send(data: MailDataRequired | MailDataRequired[], isMultiple?: boolean, cb?: (err: Error | ResponseError | null, result: [ClientResponse, {}]) => void): Promise<[ClientResponse, {}]>;

/**
* Send multiple emails (shortcut)
*/
sendMultiple(data: MailDataRequired, cb?: (error: Error | ResponseError, result: [ClientResponse, {}]) => void): Promise<[ClientResponse, {}]>;
sendMultiple(data: MailDataRequired, cb?: (error: Error | ResponseError | null, result: [ClientResponse, {}]) => void): Promise<[ClientResponse, {}]>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @collierrgbsitisfise! Thanks for the contribution. Can you add some additional tests to verify that error is null when emails are successfully delivered?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JenniferMah done, just added more test cases for mail functionality

}

declare const mail: MailService;
Expand Down
15 changes: 15 additions & 0 deletions packages/mail/src/mail.spec.js
Expand Up @@ -47,6 +47,21 @@ describe('sgMail.send()', () => {
});
});

it('should not be null(error) in callBack function for unsuccessfully delivered emails', (done) => {
sgMail.send({}, false, (error, response) => {
expect(error).to.not.be.null();
done();
});
});

it('should be null(error) in callBack function for successfully delivered emails', (done) => {
sgClient.setDefaultHeader('X-Mock', 202);
sgMail.send(data, false, (error, response) => {
expect(error).to.be.null();
done();
});
});

it('should throw an error if callback is not a function', () => {
return expect(function() {
sgMail.send(data, false, {});
Expand Down