Skip to content

Commit

Permalink
Adding template tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhonnanthn Balsas committed Jun 25, 2020
1 parent ec6f2e4 commit 5f0bca6
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/lib/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,48 @@ describe('Client', () => {
actualTemplateResponse.should.be.deep.equal(expectedTemplate);
});

it('should update template', async () => {
const expectedTemplate = {
name: 'Name of Template - SDK',
locale: 'pt_BR',
channel: 'WHATSAPP',
category: 'ACCOUNT_UPDATE',
senderId: 'sender_id',
notificationEmail: 'test@zenvia.com',
components: {
body: {
type: 'TEXT_TEMPLATE',
text: 'Hello, {{name}}. You received in your email your ticket.',
},
},
};
const zenviaNock = nock('https://api.zenvia.com')
.patch('/v1/templates/SOME_TEMPLATE_ID', {
notificationEmail: 'test@zenvia.com',
components: {
body: {
type: 'TEXT_TEMPLATE',
text: 'Hello, {{name}}. You received in your email your ticket.',
},
},
})
.matchHeader('X-API-Token', 'SOME_TOKEN')
.reply(200, expectedTemplate);

const client = new Client('SOME_TOKEN');
const actualMessageResponse = await client.updateTemplate('SOME_TEMPLATE_ID', {
notificationEmail: 'test@zenvia.com',
components: {
body: {
type: 'TEXT_TEMPLATE',
text: 'Hello, {{name}}. You received in your email your ticket.',
},
},
});
zenviaNock.isDone().should.be.true;
actualMessageResponse.should.be.deep.equal(expectedTemplate);
});

it('should delete template', async () => {
const zenviaNock = nock('https://api.zenvia.com')
.delete('/v1/templates/SOME_TEMPLATE_ID')
Expand Down

0 comments on commit 5f0bca6

Please sign in to comment.