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: ` ${code} Envio en procesamiento 1 444328681 ` } }]); 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'); }); });