fabasoad/twilio-voice-call-action

View on GitHub
__tests__/twilio-mock.js

Summary

Maintainability
A
0 mins
Test Coverage
const assert = require('assert');

module.exports = (voice, text, fromExpected, toExpected) => ({
  calls: {
    create: ({ from, to, twiml }) => new Promise((resolve, reject) => {
      try {
        assert.equal(fromExpected, from);
        assert.equal(toExpected, to);
        assert.equal(
          `<Response><Say voice="${voice}">${text}</Say></Response>`, twiml
        );
        resolve();
      } catch ({ message }) {
        reject(message);
      }
    })
  }
});