2020-03-15 15:49:34 +01:00
|
|
|
/* eslint no-multi-spaces: 0 */
|
2020-04-19 08:18:11 +02:00
|
|
|
const expect = require("chai").expect;
|
2017-03-27 14:01:30 -03:00
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
describe("Functions module currentweather", function () {
|
2017-08-06 07:53:03 -04:00
|
|
|
// Fake for use by currentweather.js
|
|
|
|
Module = {};
|
|
|
|
config = {};
|
|
|
|
Module.definitions = {};
|
|
|
|
Module.register = function (name, moduleDefinition) {
|
|
|
|
Module.definitions[name] = moduleDefinition;
|
|
|
|
};
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
before(function () {
|
2017-03-28 22:15:48 -03:00
|
|
|
require("../../../modules/default/currentweather/currentweather.js");
|
|
|
|
Module.definitions.currentweather.config = {};
|
|
|
|
});
|
2017-03-27 14:01:30 -03:00
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
describe("roundValue", function () {
|
|
|
|
describe("this.config.roundTemp is true", function () {
|
|
|
|
before(function () {
|
2017-03-28 22:15:48 -03:00
|
|
|
Module.definitions.currentweather.config.roundTemp = true;
|
|
|
|
});
|
2017-03-27 14:01:30 -03:00
|
|
|
|
2021-04-08 21:12:56 +02:00
|
|
|
const values = [
|
2017-03-27 14:01:30 -03:00
|
|
|
// index 0 value
|
|
|
|
// index 1 expect
|
2020-05-11 22:22:32 +02:00
|
|
|
[1, "1"],
|
|
|
|
[1.0, "1"],
|
|
|
|
[1.02, "1"],
|
|
|
|
[10.12, "10"],
|
|
|
|
[2.0, "2"],
|
|
|
|
["2.12", "2"],
|
|
|
|
[10.1, "10"]
|
2019-06-04 10:19:25 +02:00
|
|
|
];
|
2017-03-27 14:01:30 -03:00
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
values.forEach((value) => {
|
|
|
|
it(`for ${value[0]} should be return ${value[1]}`, function () {
|
2017-03-27 14:01:30 -03:00
|
|
|
expect(Module.definitions.currentweather.roundValue(value[0])).to.equal(value[1]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-03-28 22:15:48 -03:00
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
describe("this.config.roundTemp is false", function () {
|
|
|
|
before(function () {
|
2017-03-28 22:15:48 -03:00
|
|
|
Module.definitions.currentweather.config.roundTemp = false;
|
|
|
|
});
|
|
|
|
|
2021-04-08 21:12:56 +02:00
|
|
|
const values = [
|
2017-03-28 22:15:48 -03:00
|
|
|
// index 0 value
|
|
|
|
// index 1 expect
|
2020-05-11 22:22:32 +02:00
|
|
|
[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.1, "10.1"]
|
2019-06-04 10:19:25 +02:00
|
|
|
];
|
2017-03-28 22:15:48 -03:00
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
values.forEach((value) => {
|
|
|
|
it(`for ${value[0]} should be return ${value[1]}`, function () {
|
2017-03-28 22:15:48 -03:00
|
|
|
expect(Module.definitions.currentweather.roundValue(value[0])).to.equal(value[1]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-03-27 14:01:30 -03:00
|
|
|
});
|
|
|
|
});
|