2018-02-16 00:01:02 +01:00
|
|
|
const chai = require("chai");
|
|
|
|
const expect = chai.expect;
|
|
|
|
const path = require("path");
|
|
|
|
const {JSDOM} = require("jsdom");
|
2017-07-25 21:36:30 -04:00
|
|
|
|
|
|
|
describe("File js/class", function() {
|
|
|
|
describe("Test function cloneObject", function() {
|
2018-02-16 00:08:11 +01:00
|
|
|
let clone;
|
2018-02-16 08:43:27 +01:00
|
|
|
let dom;
|
2018-02-16 00:08:11 +01:00
|
|
|
|
|
|
|
before(function(done) {
|
2018-02-16 08:43:27 +01:00
|
|
|
dom = new JSDOM(`<script>var Log = {log: function() {}};</script>\
|
|
|
|
<script src="${path.join(__dirname, "..", "..", "..", "js", "class.js")}">`, { runScripts: "dangerously",
|
2018-02-16 00:08:11 +01:00
|
|
|
resources: "usable" });
|
|
|
|
dom.window.onload = function() {
|
|
|
|
const {cloneObject} = dom.window;
|
|
|
|
clone = cloneObject;
|
|
|
|
done();
|
|
|
|
};
|
|
|
|
});
|
2017-07-25 21:36:30 -04:00
|
|
|
|
|
|
|
it("should be return equals object", function() {
|
2018-02-16 00:08:11 +01:00
|
|
|
const expected = {name: "Rodrigo", web: "https://rodrigoramirez.com", project: "MagicMirror"};
|
|
|
|
let obj = {};
|
2018-02-16 00:01:02 +01:00
|
|
|
obj = clone(expected);
|
2017-07-25 21:36:30 -04:00
|
|
|
expect(expected).to.deep.equal(obj);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should be return equals int", function() {
|
2018-02-16 00:08:11 +01:00
|
|
|
const expected = 1;
|
2018-02-16 00:01:02 +01:00
|
|
|
let obj = {};
|
|
|
|
obj = clone(expected);
|
2017-07-25 21:36:30 -04:00
|
|
|
expect(expected).to.equal(obj);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should be return equals string", function() {
|
2018-02-16 00:08:11 +01:00
|
|
|
const expected = "Perfect stranger";
|
2018-02-16 00:01:02 +01:00
|
|
|
let obj = {};
|
|
|
|
obj = clone(expected);
|
2017-07-25 21:36:30 -04:00
|
|
|
expect(expected).to.equal(obj);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should be return equals undefined", function() {
|
2018-02-16 00:08:11 +01:00
|
|
|
const expected = undefined;
|
2018-02-16 00:01:02 +01:00
|
|
|
let obj = {};
|
|
|
|
obj = clone(expected);
|
2017-07-25 21:36:30 -04:00
|
|
|
expect(undefined).to.equal(obj);
|
|
|
|
});
|
|
|
|
|
2018-02-16 08:43:27 +01:00
|
|
|
describe("Test lockstring code", function() {
|
|
|
|
let log;
|
|
|
|
|
|
|
|
before(function() {
|
|
|
|
log = dom.window.Log.log;
|
|
|
|
dom.window.Log.log = function cmp(str) {
|
|
|
|
expect(str).to.equal("lockStrings");
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
after(function() {
|
|
|
|
dom.window.Log.log = log;
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should be return equals object and log lockStrings", function() {
|
|
|
|
const expected = {name: "Module", lockStrings: "stringLock"};
|
2018-02-16 00:01:02 +01:00
|
|
|
let obj = {};
|
|
|
|
obj = clone(expected);
|
2017-07-25 21:36:30 -04:00
|
|
|
expect(expected).to.deep.equal(obj);
|
|
|
|
});
|
2018-02-16 08:43:27 +01:00
|
|
|
|
2017-07-25 21:36:30 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|