UNPKG

1.13 kBJavaScriptView Raw
1import Redact from "../lib/Redact";
2import { expect, sinon, TestUtils } from "./NexmoTestUtils";
3
4describe("Redact", function() {
5 beforeEach(function() {
6 this.httpClientStub = TestUtils.getHttpClient();
7 sinon.stub(this.httpClientStub, "request");
8 this.redact = new Redact(TestUtils.getCredentials(), {
9 api: this.httpClientStub
10 });
11 });
12
13 afterEach(function() {
14 this.httpClientStub.request.restore();
15 });
16
17 describe("#transaction", function() {
18 it("should work with no optional fields", function() {
19 return expect(this.redact)
20 .method("transaction")
21 .withParams("ABC123", "voice")
22 .to.post.withJsonBody({ id: "ABC123", product: "voice" })
23 .to.url(`${Redact.PATH}/transaction`);
24 });
25
26 it("should pass through optional fields", function() {
27 return expect(this.redact)
28 .method("transaction")
29 .withParams("ABC123", "voice", { type: "outbound" })
30 .to.post.withJsonBody({
31 id: "ABC123",
32 product: "voice",
33 type: "outbound"
34 })
35 .to.url(`${Redact.PATH}/transaction`);
36 });
37 });
38});