|
1 | 1 | const sinon = require("sinon"); |
2 | | -const { settings } = require("@mocks-server/admin-api-client"); |
| 2 | +const adminApiClient = require("@mocks-server/admin-api-client"); |
3 | 3 |
|
4 | | -const { setBehavior, setDelay, setSettings } = require("../src/commands"); |
| 4 | +const { setBehavior, setDelay, setSettings, config } = require("../src/commands"); |
5 | 5 |
|
6 | | -describe("register", () => { |
| 6 | +describe("commands", () => { |
7 | 7 | let sandbox; |
8 | 8 |
|
9 | 9 | beforeEach(() => { |
10 | 10 | sandbox = sinon.createSandbox(); |
11 | | - sandbox.stub(settings, "update"); |
| 11 | + sandbox.stub(adminApiClient.settings, "update"); |
| 12 | + sandbox.stub(adminApiClient, "config"); |
12 | 13 | }); |
13 | 14 |
|
14 | 15 | afterEach(() => { |
15 | 16 | sandbox.restore(); |
16 | 17 | }); |
17 | 18 |
|
18 | | - describe("commands", () => { |
19 | | - describe("setBehavior command", () => { |
20 | | - it("should call to update behavior", () => { |
21 | | - setBehavior("foo-behavior"); |
22 | | - expect( |
23 | | - settings.update.calledWith({ |
24 | | - behavior: "foo-behavior" |
25 | | - }) |
26 | | - ).toBe(true); |
27 | | - }); |
| 19 | + describe("setBehavior command", () => { |
| 20 | + it("should call to update behavior", () => { |
| 21 | + setBehavior("foo-behavior"); |
| 22 | + expect( |
| 23 | + adminApiClient.settings.update.calledWith({ |
| 24 | + behavior: "foo-behavior" |
| 25 | + }) |
| 26 | + ).toBe(true); |
| 27 | + }); |
| 28 | + }); |
| 29 | + |
| 30 | + describe("setDelay command", () => { |
| 31 | + it("should call to update delay", () => { |
| 32 | + setDelay(3000); |
| 33 | + expect( |
| 34 | + adminApiClient.settings.update.calledWith({ |
| 35 | + delay: 3000 |
| 36 | + }) |
| 37 | + ).toBe(true); |
28 | 38 | }); |
| 39 | + }); |
| 40 | + |
| 41 | + describe("setSettings command", () => { |
| 42 | + it("should call to update delay", () => { |
| 43 | + setSettings("foo"); |
| 44 | + expect(adminApiClient.settings.update.calledWith("foo")).toBe(true); |
| 45 | + }); |
| 46 | + }); |
29 | 47 |
|
30 | | - describe("setDelay command", () => { |
31 | | - it("should call to update delay", () => { |
32 | | - setDelay(3000); |
33 | | - expect( |
34 | | - settings.update.calledWith({ |
35 | | - delay: 3000 |
36 | | - }) |
37 | | - ).toBe(true); |
| 48 | + describe("config method", () => { |
| 49 | + it("should call to config admin-api-client baseUrl", () => { |
| 50 | + config({ |
| 51 | + baseUrl: "foo" |
38 | 52 | }); |
| 53 | + expect( |
| 54 | + adminApiClient.config.calledWith({ |
| 55 | + baseUrl: "foo" |
| 56 | + }) |
| 57 | + ).toBe(true); |
39 | 58 | }); |
40 | 59 |
|
41 | | - describe("setSettings command", () => { |
42 | | - it("should call to update delay", () => { |
43 | | - setSettings("foo"); |
44 | | - expect(settings.update.calledWith("foo")).toBe(true); |
| 60 | + it("should call to config admin-api-client apiPath with adminApiPath value", () => { |
| 61 | + config({ |
| 62 | + adminApiPath: "foo" |
45 | 63 | }); |
| 64 | + expect( |
| 65 | + adminApiClient.config.calledWith({ |
| 66 | + apiPath: "foo" |
| 67 | + }) |
| 68 | + ).toBe(true); |
46 | 69 | }); |
47 | 70 | }); |
48 | 71 | }); |
0 commit comments