瀏覽代碼

loader configuration tests

Raanan Weber 7 年之前
父節點
當前提交
975e18ef8f
共有 2 個文件被更改,包括 56 次插入0 次删除
  1. 55 0
      Viewer/tests/unit/src/configuration/loader.ts
  2. 1 0
      Viewer/tests/unit/src/index.ts

+ 55 - 0
Viewer/tests/unit/src/configuration/loader.ts

@@ -0,0 +1,55 @@
+import { Helper } from "../../../commons/helper";
+import { assert, expect, should } from "../viewerReference";
+import { mapperManager, ViewerConfiguration } from "..";
+import { IMapper } from "../../../../src/configuration/mappers";
+import { ConfigurationLoader } from "../../../../src/configuration/loader";
+
+export let name = "configuration loader";
+
+describe("Configuration loader", () => {
+
+    it("should call callback when configuration is loaded", (done) => {
+        let configurationLoader = new ConfigurationLoader();
+
+        configurationLoader.loadConfiguration({}, (newConfig) => {
+            done();
+        });
+    });
+
+    it("should resolve the promise when configuration is loaded", (done) => {
+        let configurationLoader = new ConfigurationLoader();
+
+        configurationLoader.loadConfiguration({}).then(() => {
+            done();
+        });
+    });
+
+    it("should not change configuration is not needed initConfig", (done) => {
+        let configurationLoader = new ConfigurationLoader();
+
+        let config: ViewerConfiguration = {
+            version: "" + Math.random(),
+            extends: "none"
+        };
+        configurationLoader.loadConfiguration(config, (newConfig) => {
+            assert.deepEqual(config, newConfig);
+            done();
+        });
+    });
+
+    it("should load default configuration is no configuration extension provided", (done) => {
+        let configurationLoader = new ConfigurationLoader();
+
+        let config: ViewerConfiguration = {
+            version: "" + Math.random()
+        };
+        configurationLoader.loadConfiguration(config, (newConfig) => {
+            assert.equal(config.version, newConfig.version);
+            assert.notDeepEqual(config, newConfig);
+            assert.isDefined(newConfig.engine);
+            assert.isDefined(newConfig.scene);
+            assert.isDefined(newConfig.templates);
+            done();
+        });
+    });
+});

+ 1 - 0
Viewer/tests/unit/src/index.ts

@@ -5,4 +5,5 @@ if (window && !window['validation']) {
 import './viewer/viewer';
 import './viewer/viewerManager';
 import './configuration/mappers';
+import './configuration/loader';
 export * from '../../../src'