mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Merge pull request #982 from roramirez/doc-roundValue
Fix Documentation in roundValue function
This commit is contained in:
commit
abfdf0e1c2
@ -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 `.vscode/` folder to `.gitignore` to keep custom Visual Studio Code config out of git.
|
||||||
- Add unit test the capitalizeFirstLetter function of newfeed module.
|
- Add unit test the capitalizeFirstLetter function of newfeed module.
|
||||||
- Add new unit tests for function `shorten` in calendar module.
|
- Add new unit tests for function `shorten` in calendar module.
|
||||||
|
- Add unit tests for function `roundValue` in currentweather module.
|
||||||
- Add test e2e showWeek feature in spanish language.
|
- Add test e2e showWeek feature in spanish language.
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
|
@ -469,7 +469,7 @@ Module.register("currentweather",{
|
|||||||
*
|
*
|
||||||
* argument temperature number - Temperature.
|
* argument temperature number - Temperature.
|
||||||
*
|
*
|
||||||
* return number - Rounded Temperature.
|
* return string - Rounded Temperature.
|
||||||
*/
|
*/
|
||||||
roundValue: function(temperature) {
|
roundValue: function(temperature) {
|
||||||
var decimals = this.config.roundTemp ? 0 : 1;
|
var decimals = this.config.roundTemp ? 0 : 1;
|
||||||
|
@ -358,7 +358,7 @@ Module.register("weatherforecast",{
|
|||||||
*
|
*
|
||||||
* argument temperature number - Temperature.
|
* argument temperature number - Temperature.
|
||||||
*
|
*
|
||||||
* return number - Rounded Temperature.
|
* return string - Rounded Temperature.
|
||||||
*/
|
*/
|
||||||
roundValue: function(temperature) {
|
roundValue: function(temperature) {
|
||||||
var decimals = this.config.roundTemp ? 0 : 1;
|
var decimals = this.config.roundTemp ? 0 : 1;
|
||||||
|
78
tests/unit/functions/currentweather_spec.js
Normal file
78
tests/unit/functions/currentweather_spec.js
Normal 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]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user