Skip to content

Commit

Permalink
chore: adjust 'packages/mail/src/mail.d.ts' (#1320)
Browse files Browse the repository at this point in the history
  • Loading branch information
collierrgbsitisfise authored Jan 7, 2022
1 parent 9dc9f0f commit a6a83d1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/mail/src/mail.d.ts
Original file line number Diff line number Diff line change
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, {}]>;
}

declare const mail: MailService;
Expand Down
15 changes: 15 additions & 0 deletions packages/mail/src/mail.spec.js
Original file line number Diff line number Diff line change
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

0 comments on commit a6a83d1

Please sign in to comment.