From db83ac7bc2473c43d2b5ab1ac142119eb1fa5635 Mon Sep 17 00:00:00 2001 From: Theresa Gresch Date: Fri, 9 Aug 2019 16:00:52 +0200 Subject: [PATCH] Add test for config,js --- frontend/tests/unit/common/config_test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/frontend/tests/unit/common/config_test.js b/frontend/tests/unit/common/config_test.js index c8387fe86..743fa6b99 100644 --- a/frontend/tests/unit/common/config_test.js +++ b/frontend/tests/unit/common/config_test.js @@ -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"); + }); }); \ No newline at end of file