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;
|
2021-01-14 19:10:04 +01:00
|
|
|
const moment = require("moment-timezone");
|
2021-01-10 16:24:46 +01:00
|
|
|
var data = require("../functions/weatherforecast_data.json");
|
2017-03-29 00:29:47 -03:00
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
describe("Functions module weatherforecast", function () {
|
|
|
|
before(function () {
|
2017-03-29 00:29:47 -03:00
|
|
|
Module = {};
|
|
|
|
config = {};
|
|
|
|
Module.definitions = {};
|
|
|
|
Module.register = function (name, moduleDefinition) {
|
|
|
|
Module.definitions[name] = moduleDefinition;
|
|
|
|
};
|
|
|
|
require("../../../modules/default/weatherforecast/weatherforecast.js");
|
|
|
|
Module.definitions.weatherforecast.config = {};
|
|
|
|
});
|
|
|
|
|
2021-01-10 16:24:46 +01:00
|
|
|
describe("forecastIcons", function () {
|
|
|
|
Log = {
|
|
|
|
error: function () {}
|
|
|
|
};
|
2021-01-14 19:10:04 +01:00
|
|
|
|
|
|
|
var originalLocale;
|
|
|
|
var originalTimeZone;
|
|
|
|
before(function () {
|
|
|
|
originalLocale = moment.locale();
|
|
|
|
originalTimeZone = moment.tz.guess();
|
|
|
|
moment.locale("hi");
|
|
|
|
moment.tz.setDefault("Europe/Warsaw");
|
|
|
|
});
|
|
|
|
|
2021-01-10 16:24:46 +01:00
|
|
|
describe("forecastIcons sunset specified", function () {
|
|
|
|
before(function () {
|
|
|
|
Module.definitions.weatherforecast.Log = {};
|
|
|
|
Module.definitions.weatherforecast.forecast = [];
|
|
|
|
Module.definitions.weatherforecast.show = Module.definitions.weatherforecast.updateDom = function () {};
|
|
|
|
Module.definitions.weatherforecast.config = Module.definitions.weatherforecast.defaults;
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`returns correct icons with sunset time`, function () {
|
|
|
|
Module.definitions.weatherforecast.processWeather(data.withSunset);
|
|
|
|
let forecastData = Module.definitions.weatherforecast.forecast;
|
|
|
|
expect(forecastData.length).to.equal(4);
|
|
|
|
expect(forecastData[2].icon).to.equal("wi-rain");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("forecastIcons sunset not specified", function () {
|
|
|
|
before(function () {
|
|
|
|
Module.definitions.weatherforecast.forecast = [];
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`returns correct icons with out sunset time`, function () {
|
|
|
|
Module.definitions.weatherforecast.processWeather(data.withoutSunset);
|
|
|
|
let forecastData = Module.definitions.weatherforecast.forecast;
|
|
|
|
expect(forecastData.length).to.equal(4);
|
|
|
|
expect(forecastData[2].icon).to.equal("wi-rain");
|
|
|
|
});
|
|
|
|
});
|
2021-01-14 19:10:04 +01:00
|
|
|
|
|
|
|
after(function () {
|
|
|
|
moment.locale(originalLocale);
|
|
|
|
moment.tz.setDefault(originalTimeZone);
|
|
|
|
});
|
2021-01-10 16:24:46 +01:00
|
|
|
});
|
2017-03-29 00:29:47 -03:00
|
|
|
});
|