parent
1ab61fbc07
commit
fd97845979
|
@ -0,0 +1,27 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('client sendSms()', () => {
|
||||
let createdLog;
|
||||
|
||||
afterAll(async done => {
|
||||
await app.models.ClientLog.destroyById(createdLog.id);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should send a message and log it', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 9}}};
|
||||
let id = 101;
|
||||
let destination = 222222222;
|
||||
let message = 'this is the message created in a test';
|
||||
|
||||
let sms = await app.models.Client.sendSms(ctx, id, destination, message);
|
||||
|
||||
logId = sms.logId;
|
||||
|
||||
createdLog = await app.models.ClientLog.findById(logId);
|
||||
let json = JSON.parse(JSON.stringify(createdLog.newInstance));
|
||||
|
||||
expect(json.message).toEqual(message);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,37 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const soap = require('soap');
|
||||
|
||||
describe('sms send()', () => {
|
||||
it('should return the expected message and status code', async() => {
|
||||
const code = 200;
|
||||
const smsConfig = await app.models.SmsConfig.findOne();
|
||||
const soapClient = await soap.createClientAsync(smsConfig.uri);
|
||||
spyOn(soap, 'createClientAsync').and.returnValue(soapClient);
|
||||
spyOn(soapClient, 'sendSMSAsync').and.returnValue([{
|
||||
result: {
|
||||
$value:
|
||||
`<xtratelecom-sms-response>
|
||||
<sms>
|
||||
<codigo>
|
||||
${code}
|
||||
</codigo>
|
||||
<descripcion>
|
||||
Envio en procesamiento
|
||||
</descripcion>
|
||||
<messageId>
|
||||
1
|
||||
</messageId>
|
||||
</sms>
|
||||
<procesoId>
|
||||
444328681
|
||||
</procesoId>
|
||||
</xtratelecom-sms-response>`
|
||||
}
|
||||
}]);
|
||||
let ctx = {req: {accessToken: {userId: 1}}};
|
||||
let result = await app.models.Sms.send(ctx, 105, 'destination', 'My SMS Body');
|
||||
|
||||
expect(result.statusCode).toEqual(200);
|
||||
expect(result.status).toContain('Fake response');
|
||||
});
|
||||
});
|
|
@ -0,0 +1,27 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('ticket sendSms()', () => {
|
||||
let logId;
|
||||
|
||||
afterAll(async done => {
|
||||
await app.models.TicketLog.destroyById(logId);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should send a message and log it', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 9}}};
|
||||
let id = 11;
|
||||
let destination = 222222222;
|
||||
let message = 'this is the message created in a test';
|
||||
|
||||
let sms = await app.models.Ticket.sendSms(ctx, id, destination, message);
|
||||
|
||||
logId = sms.logId;
|
||||
|
||||
let createdLog = await app.models.TicketLog.findById(logId);
|
||||
let json = JSON.parse(JSON.stringify(createdLog.newInstance));
|
||||
|
||||
expect(json.message).toEqual(message);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue