1 | import chai, { expect } from "chai";
|
2 |
|
3 | import path from "path";
|
4 | import sinon from "sinon";
|
5 | import sinonChai from "sinon-chai";
|
6 |
|
7 | import ResourceTestHelper from "./ResourceTestHelper";
|
8 |
|
9 | import DtmfResource from "../lib/DtmfResource";
|
10 | import HttpClient from "../lib/HttpClient";
|
11 | import Credentials from "../lib/Credentials";
|
12 |
|
13 | chai.use(sinonChai);
|
14 |
|
15 | var creds = Credentials.parse({
|
16 | applicationId: "some-id",
|
17 | privateKey: path.join(__dirname, "private-test.key")
|
18 | });
|
19 | var emptyCallback = () => {};
|
20 |
|
21 | describe("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 | });
|