smartenv/test/test.js

24 lines
4.2 KiB
JavaScript

/// <reference path="../ts/typings/main.d.ts" />
var smartenv = require("../dist/index.js");
var beautylog = require("beautylog");
beautylog.info("Now testing the smartenv module");
smartenv.printEnv();
beautylog.info("Now testing the smartenv module");
//test smartenv.obs.add
smartenv.obs.add("myTestObject", { key1: "Peter" });
smartenv.obs.add("myTestObject", { key1: "Klaus" }); //now trying to add a second
smartenv.printEnv();
beautylog.log(smartenv.obs.get("myTestObject").key1); // this should be Peter
//test smartenv.obs.replace
smartenv.obs.replace("myTestObject", { key1: "Klaus" });
beautylog.log(smartenv.obs.get("myTestObject").key1); // this should be Klaus
//test smartenv.obs.merge
smartenv.obs.merge("myTestObject", { key2: "Peter" });
beautylog.log(smartenv.obs.get("myTestObject").key1 + smartenv.obs.get("myTestObject").key2); // this should be KlausPeter
var key2 = "hello";
smartenv.obs.get("myTestObject").key2 = key2;
beautylog.log(smartenv.obs.get("myTestObject").key2);
beautylog.success("Success!");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELElBQUksUUFBUSxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDO0FBQzNDLElBQUksU0FBUyxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQztBQUNyQyxTQUFTLENBQUMsSUFBSSxDQUFDLGlDQUFpQyxDQUFDLENBQUM7QUFDbEQsUUFBUSxDQUFDLFFBQVEsRUFBRSxDQUFDO0FBQ3BCLFNBQVMsQ0FBQyxJQUFJLENBQUMsaUNBQWlDLENBQUMsQ0FBQztBQUVsRCx1QkFBdUI7QUFDdkIsUUFBUSxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsY0FBYyxFQUFDLEVBQUMsSUFBSSxFQUFDLE9BQU8sRUFBQyxDQUFDLENBQUM7QUFDaEQsU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