-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: coverage on successful or erroneous requests
- Loading branch information
1 parent
2a4d9b1
commit 98c730c
Showing
8 changed files
with
140 additions
and
143 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
.env | ||
*.lock | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const mobizon = require('./config'); | ||
|
||
describe('Mobizon balance', () => { | ||
it('should receive the account balance', async () => { | ||
const response = await mobizon.getBalance(); | ||
|
||
expect(response.code).toBe(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const mobizon = require('../../src/index'); | ||
|
||
mobizon.setConfig({ | ||
apiServer: 'https://api.mobizon.com.br', | ||
apiKey: process.env.API_KEY, | ||
format: 'json', | ||
}); | ||
|
||
module.exports = mobizon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
const mobizon = require('./config'); | ||
|
||
describe('Mobizon short methods', () => { | ||
const responseValues = []; | ||
|
||
it('should create short link', async () => { | ||
const response = await mobizon.shortCreate({ | ||
fullLink: 'https://mobizon.com.br', | ||
status: 1, | ||
expirationDate: '', | ||
comment: 'Created short link.', | ||
}); | ||
|
||
responseValues.push(response.data); | ||
|
||
expect(response.code).toBe(0); | ||
}); | ||
|
||
it('should throw error when creating short link', async () => { | ||
const response = await mobizon.shortCreate({}); | ||
|
||
expect(response.code).not.toBe(0); | ||
}); | ||
|
||
it('should get short link', async () => { | ||
const response = await mobizon.shortGet([responseValues[0].code]); | ||
|
||
expect(response.code).toBe(0); | ||
}); | ||
|
||
it('should throw error when getting short link', async () => { | ||
const response = await mobizon.shortGet([]); | ||
|
||
expect(response.code).not.toBe(0); | ||
}); | ||
|
||
it('should update short link', async () => { | ||
const response = await mobizon.shortUpdate({ | ||
id: responseValues[0].id, | ||
data: { | ||
status: 0, | ||
expirationDate: '', | ||
comment: 'Updated short link.', | ||
}, | ||
}); | ||
|
||
expect(response.code).toBe(0); | ||
}); | ||
|
||
it('should throw an error when updating a short link', async () => { | ||
const response = await mobizon.shortUpdate({}); | ||
|
||
expect(response.code).not.toBe(0); | ||
}); | ||
|
||
it('should delete short link', async () => { | ||
const response = await mobizon.shortDelete([responseValues[0].id]); | ||
|
||
expect(response.code).toBe(0); | ||
}); | ||
|
||
it('should throw an error when deleting a short link', async () => { | ||
const response = await mobizon.shortDelete(); | ||
|
||
expect(response.code).not.toBe(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const mobizon = require('./config'); | ||
|
||
describe('Mobizon sms methods', () => { | ||
const recipient = process.env.NUMBER; | ||
const responseValues = []; | ||
|
||
it('should send a sms', async () => { | ||
const response = await mobizon.sendSms({ | ||
recipient, | ||
from: '', | ||
text: 'Sent sms.', | ||
}); | ||
|
||
responseValues.push(response.data); | ||
|
||
expect(response.code).toBe(0); | ||
}); | ||
|
||
it('should throw error when sending sms', async () => { | ||
const response = await mobizon.sendSms({}); | ||
|
||
expect(response.code).not.toBe(0); | ||
}); | ||
|
||
it('should list the sms sent by id', async () => { | ||
const response = await mobizon.getSms(responseValues[0].messageId); | ||
|
||
expect(response.code).toBe(0); | ||
}); | ||
|
||
it('should throw error when listing sms by id', async () => { | ||
const response = await mobizon.getSms([]); | ||
|
||
expect(response.code).not.toBe(0); | ||
}); | ||
|
||
it('should list the all sms sent', async () => { | ||
const response = await mobizon.listSms({ | ||
criteria: { | ||
from: '', | ||
}, | ||
pagination: { | ||
currentPage: '2', | ||
pageSize: '50', | ||
}, | ||
sort: { | ||
campaignId: 'ASC', | ||
}, | ||
}); | ||
|
||
expect(response.code).toBe(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.