Skip to content
This repository was archived by the owner on Mar 28, 2022. It is now read-only.

Commit 7a65f3e

Browse files
committed
Add babel-eslint dependency. Fix config unit test
1 parent 97cbeff commit 7a65f3e

File tree

4 files changed

+190
-6
lines changed

4 files changed

+190
-6
lines changed

package-lock.json

Lines changed: 152 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@babel/preset-env": "^7.7.7",
3939
"@rollup/plugin-commonjs": "^11.0.0",
4040
"@rollup/plugin-node-resolve": "^6.0.0",
41+
"babel-eslint": "^10.0.3",
4142
"babel-jest": "^24.9.0",
4243
"babel-polyfill": "^6.26.0",
4344
"coveralls": "^3.0.7",
@@ -51,7 +52,8 @@
5152
"prettier": "^1.19.1",
5253
"rollup": "^1.27.14",
5354
"rollup-plugin-babel": "^4.3.3",
54-
"rollup-plugin-uglify": "^6.0.4"
55+
"rollup-plugin-uglify": "^6.0.4",
56+
"sinon": "^8.0.1"
5557
},
5658
"lint-staged": {
5759
"test/**/*.js": "eslint",

test/index.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const index = require("../index");
1+
import { config } from "../index";
22

33
describe("Exported methods", () => {
44
it("should include config", () => {
5-
expect(index.config).toBeDefined();
5+
expect(config).toBeDefined();
66
});
77
});

test/src/config.spec.js

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,37 @@
1-
const { config } = require("../../src/config");
1+
import sinon from "sinon";
2+
import { instances } from "@data-provider/core";
3+
4+
import config from "../../src/config";
5+
import TAG from "../../src/tag";
26

37
describe("config method", () => {
4-
it("should be defined", () => {
5-
expect(config).toBeDefined();
8+
const BASE_URL = "http://localhost:3001";
9+
const API_PATH = "/foo-admin";
10+
11+
let sandbox;
12+
beforeAll(() => {
13+
sandbox = sinon.createSandbox();
14+
sandbox.spy(instances.getByTag(TAG), "config");
15+
});
16+
17+
afterAll(() => {
18+
sandbox.restore();
19+
});
20+
21+
it("should set baseUrl in admin-api-client tagged providers", () => {
22+
config({
23+
baseUrl: BASE_URL
24+
});
25+
expect(instances.getByTag(TAG).config.getCall(0).args[0].baseUrl).toEqual(`${BASE_URL}/admin`);
26+
});
27+
28+
it("should set apiPath in admin-api-client tagged providers", () => {
29+
config({
30+
baseUrl: BASE_URL,
31+
apiPath: API_PATH
32+
});
33+
expect(instances.getByTag(TAG).config.getCall(1).args[0].baseUrl).toEqual(
34+
`${BASE_URL}${API_PATH}`
35+
);
636
});
737
});

0 commit comments

Comments
 (0)