UNPKG

1.28 kBJavaScriptView Raw
1import sinon from "sinon";
2
3import nexmo from "../lib/index";
4import App from "../lib/App";
5
6import NexmoStub from "./NexmoStub";
7
8var appAPIMapping = {
9 getApplications: "get|{}",
10 createApplication: "create",
11 getApplication: "get|someAppId",
12 updateApplication: "update",
13 deleteApplication: "delete"
14};
15
16describe("App Object", function() {
17 it("should implement all v1 APIs", function() {
18 NexmoStub.checkAllFunctionsAreDefined(appAPIMapping, App);
19 });
20
21 it("should proxy the function call to the underlying `nexmo` object", function() {
22 NexmoStub.checkAllFunctionsAreCalled(appAPIMapping, App);
23 });
24
25 it("should call nexmo.getApplications if 1st param is object", function() {
26 var mock = sinon.mock(nexmo);
27 mock.expects("getApplications").once();
28
29 var app = new App(
30 {
31 apiKey: "test",
32 apiSecret: "test"
33 },
34 {
35 nexmoOverride: nexmo
36 }
37 );
38 app.get({});
39 });
40
41 it("should call nexmo.getApplication if 1st param is an app ID", function() {
42 var mock = sinon.mock(nexmo);
43 mock.expects("getApplication").once();
44
45 var app = new App(
46 {
47 apiKey: "test",
48 apiSecret: "test"
49 },
50 {
51 nexmoOverride: nexmo
52 }
53 );
54 app.get("some-app-id");
55 });
56});