diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a7bce67..a0e8e0c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Add `.vscode/` folder to `.gitignore` to keep custom Visual Studio Code config out of git. - Add unit test the capitalizeFirstLetter function of newfeed module. - Add new unit tests for function `shorten` in calendar module. +- Add unit test for js/class.js. - Add unit tests for function `roundValue` in currentweather module. - Add test e2e showWeek feature in spanish language. diff --git a/js/class.js b/js/class.js index f2fa5159..ec75f6f2 100644 --- a/js/class.js +++ b/js/class.js @@ -90,4 +90,9 @@ function cloneObject(obj) { } /*************** DO NOT EDIT THE LINE BELOW ***************/ -if (typeof module !== "undefined") { module.exports = Class; } +if (typeof module !== "undefined") { + module.exports = Class; + module.exports._test = { + cloneObject: cloneObject + } +} diff --git a/tests/unit/functions/class_spec.js b/tests/unit/functions/class_spec.js new file mode 100644 index 00000000..e2e6d521 --- /dev/null +++ b/tests/unit/functions/class_spec.js @@ -0,0 +1,51 @@ +var chai = require("chai"); +var expect = chai.expect; +var jsClass = require("../../../js/class.js"); + +describe("File js/class", function() { + describe("Test function cloneObject", function() { + var cloneObject = jsClass._test.cloneObject; + + it("should be return equals object", function() { + var expected = {name: "Rodrigo", web: "https://rodrigoramirez.com", project: "MagicMirror"}; + var obj = {}; + obj = cloneObject(expected); + expect(expected).to.deep.equal(obj); + }); + + it("should be return equals int", function() { + var expected = 1; + var obj = {}; + obj = cloneObject(expected); + expect(expected).to.equal(obj); + }); + + it("should be return equals string", function() { + var expected = "Perfect stranger"; + var obj = {}; + obj = cloneObject(expected); + expect(expected).to.equal(obj); + }); + + it("should be return equals undefined", function() { + var expected = undefined; + var obj = {}; + obj = cloneObject(expected); + expect(undefined).to.equal(obj); + }); + + // CoverageME + /* + context("Test lockstring code", function() { + it("should be return equals object", function() { + var expected = {name: "Module", lockStrings: "stringLock"}; + var obj = {}; + obj = cloneObject(expected); + expect(expected).to.deep.equal(obj); + }); + }); + */ + + }); +}); +