smartenv/test/test.js
2016-11-21 12:04:57 +01:00

21 lines
2.4 KiB
JavaScript

"use strict";
const smartenv = require("../dist/index.js");
const beautylog = require("beautylog");
smartenv.printEnv();
// 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
let key2 = 'hello';
smartenv.obs.get('myTestObject').key2 = key2;
beautylog.log(smartenv.obs.get('myTestObject').key2);
beautylog.success('Success!');
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDZDQUE0QztBQUM1Qyx1Q0FBc0M7QUFDdEMsUUFBUSxDQUFDLFFBQVEsRUFBRSxDQUFBO0FBRW5CLHdCQUF3QjtBQUN4QixRQUFRLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxjQUFjLEVBQUMsRUFBQyxJQUFJLEVBQUMsT0FBTyxFQUFDLENBQUMsQ0FBQTtBQUMvQyxRQUFRLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxjQUFjLEVBQUMsRUFBQyxJQUFJLEVBQUMsT0FBTyxFQUFDLENBQUMsQ0FBQSxDQUFDLDZCQUE2QjtBQUM3RSxRQUFRLENBQUMsUUFBUSxFQUFFLENBQUE7QUFDbkIsU0FBUyxDQUFDLEdBQUcsQ0FBQyxRQUFRLENBQUMsR0FB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