Skip to content

Commit a6a83d1

Browse files
chore: adjust 'packages/mail/src/mail.d.ts' (#1320)
1 parent 9dc9f0f commit a6a83d1

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

packages/mail/src/mail.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ declare class MailService {
3232
/**
3333
* Send email
3434
*/
35-
send(data: MailDataRequired | MailDataRequired[], isMultiple?: boolean, cb?: (err: Error | ResponseError, result: [ClientResponse, {}]) => void): Promise<[ClientResponse, {}]>;
35+
send(data: MailDataRequired | MailDataRequired[], isMultiple?: boolean, cb?: (err: Error | ResponseError | null, result: [ClientResponse, {}]) => void): Promise<[ClientResponse, {}]>;
3636

3737
/**
3838
* Send multiple emails (shortcut)
3939
*/
40-
sendMultiple(data: MailDataRequired, cb?: (error: Error | ResponseError, result: [ClientResponse, {}]) => void): Promise<[ClientResponse, {}]>;
40+
sendMultiple(data: MailDataRequired, cb?: (error: Error | ResponseError | null, result: [ClientResponse, {}]) => void): Promise<[ClientResponse, {}]>;
4141
}
4242

4343
declare const mail: MailService;

packages/mail/src/mail.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ describe('sgMail.send()', () => {
4747
});
4848
});
4949

50+
it('should not be null(error) in callBack function for unsuccessfully delivered emails', (done) => {
51+
sgMail.send({}, false, (error, response) => {
52+
expect(error).to.not.be.null();
53+
done();
54+
});
55+
});
56+
57+
it('should be null(error) in callBack function for successfully delivered emails', (done) => {
58+
sgClient.setDefaultHeader('X-Mock', 202);
59+
sgMail.send(data, false, (error, response) => {
60+
expect(error).to.be.null();
61+
done();
62+
});
63+
});
64+
5065
it('should throw an error if callback is not a function', () => {
5166
return expect(function() {
5267
sgMail.send(data, false, {});

0 commit comments

Comments
 (0)