Merge branch 'develop' into unittests/calendar

This commit is contained in:
Michael Teeuw
2017-08-10 16:27:00 +02:00
committed by GitHub
13 changed files with 215 additions and 11 deletions

View File

@@ -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);
});
});
*/
});
});

View File

@@ -0,0 +1,78 @@
var fs = require("fs");
var path = require("path");
var chai = require("chai");
var expect = chai.expect;
var vm = require("vm");
describe("Functions module currentweather", function() {
// Fake for use by currentweather.js
Module = {};
config = {};
Module.definitions = {};
Module.register = function (name, moduleDefinition) {
Module.definitions[name] = moduleDefinition;
};
before(function(){
require("../../../modules/default/currentweather/currentweather.js");
Module.definitions.currentweather.config = {};
});
describe("roundValue", function() {
describe("this.config.roundTemp is true", function() {
before(function(){
Module.definitions.currentweather.config.roundTemp = true;
});
var values = [
// index 0 value
// index 1 expect
[1 , "1"],
[1.0 , "1"],
[1.02 , "1"],
[10.12 , "10"],
[2.0 , "2"],
["2.12" , "2"],
[10.1 , "10"]
]
values.forEach(value => {
it(`for ${value[0]} should be return ${value[1]}`, function() {
expect(Module.definitions.currentweather.roundValue(value[0])).to.equal(value[1]);
});
});
});
describe("this.config.roundTemp is false", function() {
before(function(){
Module.definitions.currentweather.config.roundTemp = false;
});
var values = [
// index 0 value
// index 1 expect
[1 , "1.0"],
[1.0 , "1.0"],
[1.02 , "1.0"],
[10.12 , "10.1"],
[2.0 , "2.0"],
["2.12" , "2.1"],
[10.1 , "10.1"],
[10.10 , "10.1"]
]
values.forEach(value => {
it(`for ${value[0]} should be return ${value[1]}`, function() {
expect(Module.definitions.currentweather.roundValue(value[0])).to.equal(value[1]);
});
});
});
});
});