Add test for config,js
This commit is contained in:
parent
9112d30711
commit
db83ac7bc2
1 changed files with 18 additions and 0 deletions
|
@ -1,6 +1,12 @@
|
|||
import assert from "assert";
|
||||
import Config from "common/config";
|
||||
import MockAdapter from "axios-mock-adapter";
|
||||
import Api from "common/api";
|
||||
|
||||
const mock = new MockAdapter(Api);
|
||||
|
||||
mock
|
||||
.onGet("config").reply(200, {fromServer: "yes"});
|
||||
|
||||
describe("common/config", () => {
|
||||
it("should get all config values", () => {
|
||||
|
@ -47,4 +53,16 @@ describe("common/config", () => {
|
|||
const result = config.getValue("city");
|
||||
assert.equal(result, "Berlin");
|
||||
});
|
||||
|
||||
it("should pull from server", async() => {
|
||||
const storage = window.localStorage;
|
||||
const values = {name: "testConfig", year: "2300"};
|
||||
|
||||
const config = new Config(storage, values);
|
||||
const result = config.getValues();
|
||||
assert.equal(result.name, "testConfig");
|
||||
assert.equal(config.values.fromServer, undefined);
|
||||
await config.pullFromServer();
|
||||
assert.equal(config.values.fromServer, "yes");
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue