Skip to content

Instantly share code, notes, and snippets.

@pmendonca
Last active April 24, 2019 17:25
Show Gist options
  • Save pmendonca/5c38c88ec756415d9da441100cc8ea60 to your computer and use it in GitHub Desktop.
Save pmendonca/5c38c88ec756415d9da441100cc8ea60 to your computer and use it in GitHub Desktop.
Twilio Jest Mock
const mockConferences = () => ({
participants: () => (
{ update: () => Promise.resolve({}) }
)
})
mockConferences.list = () => Promise.resolve([])
module.exports = class Twilio {
constructor (sid, token) {
this.calls = {
create: () => Promise.resolve({ foo: 'bar' }),
list: () => Promise.resolve([{ sid: '123' }])
}
this.conferences = mockConferences
this.taskrouter = {
workspaces: () => {
return {
workers: {
list: () => [{ attributes: '{}' }]
},
tasks: () => ({
fetch: () => ({ attributes: '' })
})
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment