loader.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { Helper } from "../../../commons/helper";
  2. import { assert, expect, should } from "../viewerReference";
  3. import { mapperManager, ViewerConfiguration } from "..";
  4. import { IMapper } from "../../../../src/configuration/mappers";
  5. import { ConfigurationLoader } from "../../../../src/configuration/loader";
  6. export let name = "configuration loader";
  7. describe("Configuration loader", () => {
  8. it("should call callback when configuration is loaded", (done) => {
  9. let configurationLoader = new ConfigurationLoader();
  10. configurationLoader.loadConfiguration({}, (newConfig) => {
  11. done();
  12. });
  13. });
  14. it("should resolve the promise when configuration is loaded", (done) => {
  15. let configurationLoader = new ConfigurationLoader();
  16. configurationLoader.loadConfiguration({}).then(() => {
  17. done();
  18. });
  19. });
  20. it("should not change configuration is not needed initConfig", (done) => {
  21. let configurationLoader = new ConfigurationLoader();
  22. let config: ViewerConfiguration = {
  23. version: "" + Math.random(),
  24. extends: "none"
  25. };
  26. configurationLoader.loadConfiguration(config, (newConfig) => {
  27. assert.deepEqual(config, newConfig);
  28. done();
  29. });
  30. });
  31. it("should load default configuration is no configuration extension provided", (done) => {
  32. let configurationLoader = new ConfigurationLoader();
  33. let config: ViewerConfiguration = {
  34. version: "" + Math.random()
  35. };
  36. configurationLoader.loadConfiguration(config, (newConfig) => {
  37. assert.equal(config.version, newConfig.version);
  38. assert.notDeepEqual(config, newConfig);
  39. assert.isDefined(newConfig.engine);
  40. assert.isDefined(newConfig.scene);
  41. assert.isDefined(newConfig.templates);
  42. done();
  43. });
  44. });
  45. });