mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 20:22:53 +00:00
Add roundValue unit test function currentweather module:
- tests for this.config.roundTemp is false
This commit is contained in:
parent
181cb235df
commit
af9fdfa224
@ -7,21 +7,23 @@ var vm = require("vm");
|
||||
|
||||
describe("Functions module currentweather", function() {
|
||||
|
||||
// Fake for use by calendar.js
|
||||
Module = {}
|
||||
Module.definitions = {};
|
||||
Module.register = function (name, moduleDefinition) {
|
||||
Module.definitions[name] = moduleDefinition;
|
||||
};
|
||||
config = {};
|
||||
before(function(){
|
||||
Module = {};
|
||||
config = {};
|
||||
Module.definitions = {};
|
||||
Module.register = function (name, moduleDefinition) {
|
||||
Module.definitions[name] = moduleDefinition;
|
||||
};
|
||||
require("../../../modules/default/currentweather/currentweather.js");
|
||||
Module.definitions.currentweather.config = {};
|
||||
});
|
||||
|
||||
describe("roundValue", function() {
|
||||
describe("this.config.roundTemp is true", function() {
|
||||
// load currentweather
|
||||
require("../../../modules/default/currentweather/currentweather.js");
|
||||
|
||||
Module.definitions.currentweather.config = {};
|
||||
Module.definitions.currentweather.config.roundTemp = true;
|
||||
describe("this.config.roundTemp is true", function() {
|
||||
before(function(){
|
||||
Module.definitions.currentweather.config.roundTemp = true;
|
||||
});
|
||||
|
||||
var values = [
|
||||
// index 0 value
|
||||
@ -41,5 +43,32 @@ describe("Functions module currentweather", function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
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]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user