UNPKG

1.27 kBJavaScriptView Raw
1import chai, { expect } from "chai";
2
3import path from "path";
4import sinon from "sinon";
5import sinonChai from "sinon-chai";
6
7import ResourceTestHelper from "./ResourceTestHelper";
8
9import DtmfResource from "../lib/DtmfResource";
10import HttpClient from "../lib/HttpClient";
11import Credentials from "../lib/Credentials";
12
13chai.use(sinonChai);
14
15var creds = Credentials.parse({
16 applicationId: "some-id",
17 privateKey: path.join(__dirname, "private-test.key")
18});
19var emptyCallback = () => {};
20
21describe("DtmfResource", () => {
22 var httpClientStub = null;
23 var dtmf = null;
24
25 beforeEach(() => {
26 httpClientStub = sinon.createStubInstance(HttpClient);
27 var options = {
28 httpClient: httpClientStub
29 };
30 dtmf = new DtmfResource(creds, options);
31 });
32
33 it("should be able to send DTMF to a call", () => {
34 const callId = "2342342-lkjhlkjh-32423";
35 var params = {
36 digits: [1, 2, 3, 4]
37 };
38 dtmf.send(callId, params, emptyCallback);
39
40 var expectedRequestArgs = ResourceTestHelper.requestArgsMatch(params, {
41 path: DtmfResource.PATH.replace("{call_uuid}", callId),
42 method: "PUT"
43 });
44 expect(httpClientStub.request).to.have.been.calledWith(
45 sinon.match(expectedRequestArgs),
46 emptyCallback
47 );
48 });
49});