mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
remove chai from unit tests
This commit is contained in:
parent
66759a33fa
commit
16bbb42b8d
@ -1,16 +1,15 @@
|
|||||||
const expect = require("chai").expect;
|
|
||||||
const deprecated = require("../../../js/deprecated");
|
const deprecated = require("../../../js/deprecated");
|
||||||
|
|
||||||
describe("Deprecated", function () {
|
describe("Deprecated", function () {
|
||||||
it("should be an object", function () {
|
it("should be an object", function () {
|
||||||
expect(deprecated).to.be.an("object");
|
expect(typeof deprecated).toBe("object");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should contain configs array with deprecated options as strings", function () {
|
it("should contain configs array with deprecated options as strings", function () {
|
||||||
expect(deprecated.configs).to.be.an("array");
|
expect(Array.isArray(["deprecated.configs"])).toBe(true);
|
||||||
for (let option of deprecated.configs) {
|
for (let option of deprecated.configs) {
|
||||||
expect(option).to.be.an("string");
|
expect(typeof option).toBe("string");
|
||||||
}
|
}
|
||||||
expect(deprecated.configs).to.include("kioskmode");
|
expect(deprecated.configs).toEqual(expect.arrayContaining(["kioskmode"]));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
const expect = require("chai").expect;
|
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const helmet = require("helmet");
|
const helmet = require("helmet");
|
||||||
const { JSDOM } = require("jsdom");
|
const { JSDOM } = require("jsdom");
|
||||||
@ -82,9 +81,9 @@ describe("Translator", function () {
|
|||||||
const { Translator } = dom.window;
|
const { Translator } = dom.window;
|
||||||
setTranslations(Translator);
|
setTranslations(Translator);
|
||||||
let translation = Translator.translate({ name: "MMM-Module" }, "Hello");
|
let translation = Translator.translate({ name: "MMM-Module" }, "Hello");
|
||||||
expect(translation).to.be.equal("Hallo");
|
expect(translation).toBe("Hallo");
|
||||||
translation = Translator.translate({ name: "MMM-Module" }, "Hello {username}", { username: "fewieden" });
|
translation = Translator.translate({ name: "MMM-Module" }, "Hello {username}", { username: "fewieden" });
|
||||||
expect(translation).to.be.equal("Hallo fewieden");
|
expect(translation).toBe("Hallo fewieden");
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -95,9 +94,9 @@ describe("Translator", function () {
|
|||||||
const { Translator } = dom.window;
|
const { Translator } = dom.window;
|
||||||
setTranslations(Translator);
|
setTranslations(Translator);
|
||||||
let translation = Translator.translate({ name: "MMM-Module" }, "FOO");
|
let translation = Translator.translate({ name: "MMM-Module" }, "FOO");
|
||||||
expect(translation).to.be.equal("Foo");
|
expect(translation).toBe("Foo");
|
||||||
translation = Translator.translate({ name: "MMM-Module" }, "BAR {something}", { something: "Lorem Ipsum" });
|
translation = Translator.translate({ name: "MMM-Module" }, "BAR {something}", { something: "Lorem Ipsum" });
|
||||||
expect(translation).to.be.equal("Bar Lorem Ipsum");
|
expect(translation).toBe("Bar Lorem Ipsum");
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -108,7 +107,7 @@ describe("Translator", function () {
|
|||||||
const { Translator } = dom.window;
|
const { Translator } = dom.window;
|
||||||
setTranslations(Translator);
|
setTranslations(Translator);
|
||||||
const translation = Translator.translate({ name: "MMM-Module" }, "A key");
|
const translation = Translator.translate({ name: "MMM-Module" }, "A key");
|
||||||
expect(translation).to.be.equal("A translation");
|
expect(translation).toBe("A translation");
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -119,7 +118,7 @@ describe("Translator", function () {
|
|||||||
const { Translator } = dom.window;
|
const { Translator } = dom.window;
|
||||||
setTranslations(Translator);
|
setTranslations(Translator);
|
||||||
const translation = Translator.translate({ name: "MMM-Module" }, "Fallback");
|
const translation = Translator.translate({ name: "MMM-Module" }, "Fallback");
|
||||||
expect(translation).to.be.equal("core fallback");
|
expect(translation).toBe("core fallback");
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -130,7 +129,7 @@ describe("Translator", function () {
|
|||||||
const { Translator } = dom.window;
|
const { Translator } = dom.window;
|
||||||
setTranslations(Translator);
|
setTranslations(Translator);
|
||||||
const translation = Translator.translate({ name: "MMM-Module" }, "Hello {username}");
|
const translation = Translator.translate({ name: "MMM-Module" }, "Hello {username}");
|
||||||
expect(translation).to.be.equal("Hallo {username}");
|
expect(translation).toBe("Hallo {username}");
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -141,7 +140,7 @@ describe("Translator", function () {
|
|||||||
const { Translator } = dom.window;
|
const { Translator } = dom.window;
|
||||||
setTranslations(Translator);
|
setTranslations(Translator);
|
||||||
const translation = Translator.translate({ name: "MMM-Module" }, "MISSING");
|
const translation = Translator.translate({ name: "MMM-Module" }, "MISSING");
|
||||||
expect(translation).to.be.equal("MISSING");
|
expect(translation).toBe("MISSING");
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -163,7 +162,7 @@ describe("Translator", function () {
|
|||||||
|
|
||||||
Translator.load(mmm, file, false, function () {
|
Translator.load(mmm, file, false, function () {
|
||||||
const json = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", file));
|
const json = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", file));
|
||||||
expect(Translator.translations[mmm.name]).to.be.deep.equal(json);
|
expect(Translator.translations[mmm.name]).toEqual(json);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -177,7 +176,7 @@ describe("Translator", function () {
|
|||||||
|
|
||||||
Translator.load(mmm, file, true, function () {
|
Translator.load(mmm, file, true, function () {
|
||||||
const json = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", file));
|
const json = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", file));
|
||||||
expect(Translator.translationsFallback[mmm.name]).to.be.deep.equal(json);
|
expect(Translator.translationsFallback[mmm.name]).toEqual(json);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -198,8 +197,8 @@ describe("Translator", function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Translator.load(mmm, file, false, function () {
|
Translator.load(mmm, file, false, function () {
|
||||||
expect(Translator.translations[mmm.name]).to.be.equal(undefined);
|
expect(Translator.translations[mmm.name]).toBe(undefined);
|
||||||
expect(Translator.translationsFallback[mmm.name]).to.be.deep.equal({
|
expect(Translator.translationsFallback[mmm.name]).toEqual({
|
||||||
Hello: "Hallo"
|
Hello: "Hallo"
|
||||||
});
|
});
|
||||||
done();
|
done();
|
||||||
@ -221,8 +220,8 @@ describe("Translator", function () {
|
|||||||
|
|
||||||
const en = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", "en.json"));
|
const en = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", "en.json"));
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
expect(Translator.coreTranslations).to.be.deep.equal(en);
|
expect(Translator.coreTranslations).toEqual(en);
|
||||||
expect(Translator.coreTranslationsFallback).to.be.deep.equal(en);
|
expect(Translator.coreTranslationsFallback).toEqual(en);
|
||||||
done();
|
done();
|
||||||
}, 500);
|
}, 500);
|
||||||
};
|
};
|
||||||
@ -240,8 +239,8 @@ describe("Translator", function () {
|
|||||||
|
|
||||||
const en = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", "en.json"));
|
const en = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", "en.json"));
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
expect(Translator.coreTranslations).to.be.deep.equal({});
|
expect(Translator.coreTranslations).toEqual({});
|
||||||
expect(Translator.coreTranslationsFallback).to.be.deep.equal(en);
|
expect(Translator.coreTranslationsFallback).toEqual(en);
|
||||||
done();
|
done();
|
||||||
}, 500);
|
}, 500);
|
||||||
};
|
};
|
||||||
@ -261,7 +260,7 @@ describe("Translator", function () {
|
|||||||
|
|
||||||
const en = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", "en.json"));
|
const en = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", "en.json"));
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
expect(Translator.coreTranslationsFallback).to.be.deep.equal(en);
|
expect(Translator.coreTranslationsFallback).toEqual(en);
|
||||||
done();
|
done();
|
||||||
}, 500);
|
}, 500);
|
||||||
};
|
};
|
||||||
@ -278,7 +277,7 @@ describe("Translator", function () {
|
|||||||
Translator.loadCoreTranslations();
|
Translator.loadCoreTranslations();
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
expect(Translator.coreTranslationsFallback).to.be.deep.equal({});
|
expect(Translator.coreTranslationsFallback).toEqual({});
|
||||||
done();
|
done();
|
||||||
}, 500);
|
}, 500);
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
const expect = require("chai").expect;
|
|
||||||
const Utils = require("../../../js/utils.js");
|
const Utils = require("../../../js/utils.js");
|
||||||
const colors = require("colors/safe");
|
const colors = require("colors/safe");
|
||||||
|
|
||||||
@ -11,29 +10,29 @@ describe("Utils", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should have info, warn and error properties", function () {
|
it("should have info, warn and error properties", function () {
|
||||||
expect(Utils.colors).to.have.property("info");
|
expect(Utils.colors).toHaveProperty("info");
|
||||||
expect(Utils.colors).to.have.property("warn");
|
expect(Utils.colors).toHaveProperty("warn");
|
||||||
expect(Utils.colors).to.have.property("error");
|
expect(Utils.colors).toHaveProperty("error");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("properties should be functions", function () {
|
it("properties should be functions", function () {
|
||||||
expect(Utils.colors.info).to.be.a("function");
|
expect(typeof Utils.colors.info).toBe("function");
|
||||||
expect(Utils.colors.warn).to.be.a("function");
|
expect(typeof Utils.colors.warn).toBe("function");
|
||||||
expect(Utils.colors.error).to.be.a("function");
|
expect(typeof Utils.colors.error).toBe("function");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should print colored message in supported consoles", function () {
|
it("should print colored message in supported consoles", function () {
|
||||||
colors.enabled = true;
|
colors.enabled = true;
|
||||||
expect(Utils.colors.info("some informations")).to.be.equal("\u001b[34msome informations\u001b[39m");
|
expect(Utils.colors.info("some informations")).toBe("\u001b[34msome informations\u001b[39m");
|
||||||
expect(Utils.colors.warn("a warning")).to.be.equal("\u001b[33ma warning\u001b[39m");
|
expect(Utils.colors.warn("a warning")).toBe("\u001b[33ma warning\u001b[39m");
|
||||||
expect(Utils.colors.error("ERROR!")).to.be.equal("\u001b[31mERROR!\u001b[39m");
|
expect(Utils.colors.error("ERROR!")).toBe("\u001b[31mERROR!\u001b[39m");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should print message in unsupported consoles", function () {
|
it("should print message in unsupported consoles", function () {
|
||||||
colors.enabled = false;
|
colors.enabled = false;
|
||||||
expect(Utils.colors.info("some informations")).to.be.equal("some informations");
|
expect(Utils.colors.info("some informations")).toBe("some informations");
|
||||||
expect(Utils.colors.warn("a warning")).to.be.equal("a warning");
|
expect(Utils.colors.warn("a warning")).toBe("a warning");
|
||||||
expect(Utils.colors.error("ERROR!")).to.be.equal("ERROR!");
|
expect(Utils.colors.error("ERROR!")).toBe("ERROR!");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
const expect = require("chai").expect;
|
|
||||||
|
|
||||||
global.moment = require("moment");
|
global.moment = require("moment");
|
||||||
|
|
||||||
describe("Functions into modules/default/calendar/calendar.js", function () {
|
describe("Functions into modules/default/calendar/calendar.js", function () {
|
||||||
@ -26,63 +24,63 @@ describe("Functions into modules/default/calendar/calendar.js", function () {
|
|||||||
|
|
||||||
Object.keys(words).forEach((word) => {
|
Object.keys(words).forEach((word) => {
|
||||||
it(`for '${word}' should return '${words[word]}'`, function () {
|
it(`for '${word}' should return '${words[word]}'`, function () {
|
||||||
expect(Module.definitions.calendar.capFirst(word)).to.equal(words[word]);
|
expect(Module.definitions.calendar.capFirst(word)).toBe(words[word]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("getLocaleSpecification", function () {
|
describe("getLocaleSpecification", function () {
|
||||||
it("should return a valid moment.LocaleSpecification for a 12-hour format", function () {
|
it("should return a valid moment.LocaleSpecification for a 12-hour format", function () {
|
||||||
expect(Module.definitions.calendar.getLocaleSpecification(12)).to.deep.equal({ longDateFormat: { LT: "h:mm A" } });
|
expect(Module.definitions.calendar.getLocaleSpecification(12)).toEqual({ longDateFormat: { LT: "h:mm A" } });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return a valid moment.LocaleSpecification for a 24-hour format", function () {
|
it("should return a valid moment.LocaleSpecification for a 24-hour format", function () {
|
||||||
expect(Module.definitions.calendar.getLocaleSpecification(24)).to.deep.equal({ longDateFormat: { LT: "HH:mm" } });
|
expect(Module.definitions.calendar.getLocaleSpecification(24)).toEqual({ longDateFormat: { LT: "HH:mm" } });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return the current system locale when called without timeFormat number", function () {
|
it("should return the current system locale when called without timeFormat number", function () {
|
||||||
expect(Module.definitions.calendar.getLocaleSpecification()).to.deep.equal({ longDateFormat: { LT: moment.localeData().longDateFormat("LT") } });
|
expect(Module.definitions.calendar.getLocaleSpecification()).toEqual({ longDateFormat: { LT: moment.localeData().longDateFormat("LT") } });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return a 12-hour longDateFormat when using the 'en' locale", function () {
|
it("should return a 12-hour longDateFormat when using the 'en' locale", function () {
|
||||||
const localeBackup = moment.locale();
|
const localeBackup = moment.locale();
|
||||||
moment.locale("en");
|
moment.locale("en");
|
||||||
expect(Module.definitions.calendar.getLocaleSpecification()).to.deep.equal({ longDateFormat: { LT: "h:mm A" } });
|
expect(Module.definitions.calendar.getLocaleSpecification()).toEqual({ longDateFormat: { LT: "h:mm A" } });
|
||||||
moment.locale(localeBackup);
|
moment.locale(localeBackup);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return a 12-hour longDateFormat when using the 'au' locale", function () {
|
it("should return a 12-hour longDateFormat when using the 'au' locale", function () {
|
||||||
const localeBackup = moment.locale();
|
const localeBackup = moment.locale();
|
||||||
moment.locale("au");
|
moment.locale("au");
|
||||||
expect(Module.definitions.calendar.getLocaleSpecification()).to.deep.equal({ longDateFormat: { LT: "h:mm A" } });
|
expect(Module.definitions.calendar.getLocaleSpecification()).toEqual({ longDateFormat: { LT: "h:mm A" } });
|
||||||
moment.locale(localeBackup);
|
moment.locale(localeBackup);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return a 12-hour longDateFormat when using the 'eg' locale", function () {
|
it("should return a 12-hour longDateFormat when using the 'eg' locale", function () {
|
||||||
const localeBackup = moment.locale();
|
const localeBackup = moment.locale();
|
||||||
moment.locale("eg");
|
moment.locale("eg");
|
||||||
expect(Module.definitions.calendar.getLocaleSpecification()).to.deep.equal({ longDateFormat: { LT: "h:mm A" } });
|
expect(Module.definitions.calendar.getLocaleSpecification()).toEqual({ longDateFormat: { LT: "h:mm A" } });
|
||||||
moment.locale(localeBackup);
|
moment.locale(localeBackup);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return a 24-hour longDateFormat when using the 'nl' locale", function () {
|
it("should return a 24-hour longDateFormat when using the 'nl' locale", function () {
|
||||||
const localeBackup = moment.locale();
|
const localeBackup = moment.locale();
|
||||||
moment.locale("nl");
|
moment.locale("nl");
|
||||||
expect(Module.definitions.calendar.getLocaleSpecification()).to.deep.equal({ longDateFormat: { LT: "HH:mm" } });
|
expect(Module.definitions.calendar.getLocaleSpecification()).toEqual({ longDateFormat: { LT: "HH:mm" } });
|
||||||
moment.locale(localeBackup);
|
moment.locale(localeBackup);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return a 24-hour longDateFormat when using the 'fr' locale", function () {
|
it("should return a 24-hour longDateFormat when using the 'fr' locale", function () {
|
||||||
const localeBackup = moment.locale();
|
const localeBackup = moment.locale();
|
||||||
moment.locale("fr");
|
moment.locale("fr");
|
||||||
expect(Module.definitions.calendar.getLocaleSpecification()).to.deep.equal({ longDateFormat: { LT: "HH:mm" } });
|
expect(Module.definitions.calendar.getLocaleSpecification()).toEqual({ longDateFormat: { LT: "HH:mm" } });
|
||||||
moment.locale(localeBackup);
|
moment.locale(localeBackup);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return a 24-hour longDateFormat when using the 'uk' locale", function () {
|
it("should return a 24-hour longDateFormat when using the 'uk' locale", function () {
|
||||||
const localeBackup = moment.locale();
|
const localeBackup = moment.locale();
|
||||||
moment.locale("uk");
|
moment.locale("uk");
|
||||||
expect(Module.definitions.calendar.getLocaleSpecification()).to.deep.equal({ longDateFormat: { LT: "HH:mm" } });
|
expect(Module.definitions.calendar.getLocaleSpecification()).toEqual({ longDateFormat: { LT: "HH:mm" } });
|
||||||
moment.locale(localeBackup);
|
moment.locale(localeBackup);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -97,32 +95,32 @@ describe("Functions into modules/default/calendar/calendar.js", function () {
|
|||||||
|
|
||||||
Object.keys(strings).forEach((string) => {
|
Object.keys(strings).forEach((string) => {
|
||||||
it(`for '${string}' should return '${strings[string].return}'`, function () {
|
it(`for '${string}' should return '${strings[string].return}'`, function () {
|
||||||
expect(Module.definitions.calendar.shorten(string, strings[string].length)).to.equal(strings[string].return);
|
expect(Module.definitions.calendar.shorten(string, strings[string].length)).toBe(strings[string].return);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return an empty string if shorten is called with a non-string", function () {
|
it("should return an empty string if shorten is called with a non-string", function () {
|
||||||
expect(Module.definitions.calendar.shorten(100)).to.equal("");
|
expect(Module.definitions.calendar.shorten(100)).toBe("");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not shorten the string if shorten is called with a non-number maxLength", function () {
|
it("should not shorten the string if shorten is called with a non-number maxLength", function () {
|
||||||
expect(Module.definitions.calendar.shorten("This is a test string", "This is not a number")).to.equal("This is a test string");
|
expect(Module.definitions.calendar.shorten("This is a test string", "This is not a number")).toBe("This is a test string");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should wrap the string instead of shorten it if shorten is called with wrapEvents = true (with maxLength defined as 20)", function () {
|
it("should wrap the string instead of shorten it if shorten is called with wrapEvents = true (with maxLength defined as 20)", function () {
|
||||||
expect(Module.definitions.calendar.shorten("This is a wrapEvent test. Should wrap the string instead of shorten it if called with wrapEvent = true", 20, true)).to.equal(
|
expect(Module.definitions.calendar.shorten("This is a wrapEvent test. Should wrap the string instead of shorten it if called with wrapEvent = true", 20, true)).toBe(
|
||||||
"This is a <br>wrapEvent test. Should wrap <br>the string instead of <br>shorten it if called with <br>wrapEvent = true"
|
"This is a <br>wrapEvent test. Should wrap <br>the string instead of <br>shorten it if called with <br>wrapEvent = true"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should wrap the string instead of shorten it if shorten is called with wrapEvents = true (without maxLength defined, default 25)", function () {
|
it("should wrap the string instead of shorten it if shorten is called with wrapEvents = true (without maxLength defined, default 25)", function () {
|
||||||
expect(Module.definitions.calendar.shorten("This is a wrapEvent test. Should wrap the string instead of shorten it if called with wrapEvent = true", undefined, true)).to.equal(
|
expect(Module.definitions.calendar.shorten("This is a wrapEvent test. Should wrap the string instead of shorten it if called with wrapEvent = true", undefined, true)).toBe(
|
||||||
"This is a wrapEvent <br>test. Should wrap the string <br>instead of shorten it if called <br>with wrapEvent = true"
|
"This is a wrapEvent <br>test. Should wrap the string <br>instead of shorten it if called <br>with wrapEvent = true"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should wrap and shorten the string in the second line if called with wrapEvents = true and maxTitleLines = 2", function () {
|
it("should wrap and shorten the string in the second line if called with wrapEvents = true and maxTitleLines = 2", function () {
|
||||||
expect(Module.definitions.calendar.shorten("This is a wrapEvent and maxTitleLines test. Should wrap and shorten the string in the second line if called with wrapEvents = true and maxTitleLines = 2", undefined, true, 2)).to.equal(
|
expect(Module.definitions.calendar.shorten("This is a wrapEvent and maxTitleLines test. Should wrap and shorten the string in the second line if called with wrapEvents = true and maxTitleLines = 2", undefined, true, 2)).toBe(
|
||||||
"This is a wrapEvent and <br>maxTitleLines test. Should wrap and …"
|
"This is a wrapEvent and <br>maxTitleLines test. Should wrap and …"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
const expect = require("chai").expect;
|
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const { JSDOM } = require("jsdom");
|
const { JSDOM } = require("jsdom");
|
||||||
|
|
||||||
@ -19,14 +18,14 @@ describe("Test function cmpVersions in js/module.js", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should return -1 when comparing 2.1 to 2.2", function () {
|
it("should return -1 when comparing 2.1 to 2.2", function () {
|
||||||
expect(cmp("2.1", "2.2")).to.equal(-1);
|
expect(cmp("2.1", "2.2")).toBe(-1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be return 0 when comparing 2.2 to 2.2", function () {
|
it("should be return 0 when comparing 2.2 to 2.2", function () {
|
||||||
expect(cmp("2.2", "2.2")).to.equal(0);
|
expect(cmp("2.2", "2.2")).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be return 1 when comparing 1.1 to 1.0", function () {
|
it("should be return 1 when comparing 1.1 to 1.0", function () {
|
||||||
expect(cmp("1.1", "1.0")).to.equal(1);
|
expect(cmp("1.1", "1.0")).toBe(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
/* eslint no-multi-spaces: 0 */
|
/* eslint no-multi-spaces: 0 */
|
||||||
const expect = require("chai").expect;
|
|
||||||
|
|
||||||
describe("Functions module currentweather", function () {
|
describe("Functions module currentweather", function () {
|
||||||
// Fake for use by currentweather.js
|
// Fake for use by currentweather.js
|
||||||
Module = {};
|
Module = {};
|
||||||
@ -35,7 +33,7 @@ describe("Functions module currentweather", function () {
|
|||||||
|
|
||||||
values.forEach((value) => {
|
values.forEach((value) => {
|
||||||
it(`for ${value[0]} should be return ${value[1]}`, function () {
|
it(`for ${value[0]} should be return ${value[1]}`, function () {
|
||||||
expect(Module.definitions.currentweather.roundValue(value[0])).to.equal(value[1]);
|
expect(Module.definitions.currentweather.roundValue(value[0])).toBe(value[1]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -60,7 +58,7 @@ describe("Functions module currentweather", function () {
|
|||||||
|
|
||||||
values.forEach((value) => {
|
values.forEach((value) => {
|
||||||
it(`for ${value[0]} should be return ${value[1]}`, function () {
|
it(`for ${value[0]} should be return ${value[1]}`, function () {
|
||||||
expect(Module.definitions.currentweather.roundValue(value[0])).to.equal(value[1]);
|
expect(Module.definitions.currentweather.roundValue(value[0])).toBe(value[1]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
const expect = require("chai").expect;
|
|
||||||
|
|
||||||
describe("Functions into modules/default/newsfeed/newsfeed.js", function () {
|
describe("Functions into modules/default/newsfeed/newsfeed.js", function () {
|
||||||
// Fake for use by newsletter.js
|
// Fake for use by newsletter.js
|
||||||
Module = {};
|
Module = {};
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
/* eslint no-multi-spaces: 0 */
|
/* eslint no-multi-spaces: 0 */
|
||||||
const expect = require("chai").expect;
|
|
||||||
const moment = require("moment-timezone");
|
const moment = require("moment-timezone");
|
||||||
const data = require("../../configs/data/weatherforecast_data.json");
|
const data = require("../../configs/data/weatherforecast_data.json");
|
||||||
|
|
||||||
@ -35,7 +34,7 @@ describe("Functions module weatherforecast", function () {
|
|||||||
|
|
||||||
values.forEach((value) => {
|
values.forEach((value) => {
|
||||||
it(`for ${value[0]} should be return ${value[1]}`, function () {
|
it(`for ${value[0]} should be return ${value[1]}`, function () {
|
||||||
expect(Module.definitions.weatherforecast.roundValue(value[0])).to.equal(value[1]);
|
expect(Module.definitions.weatherforecast.roundValue(value[0])).toBe(value[1]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -60,7 +59,7 @@ describe("Functions module weatherforecast", function () {
|
|||||||
|
|
||||||
values.forEach((value) => {
|
values.forEach((value) => {
|
||||||
it(`for ${value[0]} should be return ${value[1]}`, function () {
|
it(`for ${value[0]} should be return ${value[1]}`, function () {
|
||||||
expect(Module.definitions.weatherforecast.roundValue(value[0])).to.equal(value[1]);
|
expect(Module.definitions.weatherforecast.roundValue(value[0])).toBe(value[1]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -91,8 +90,8 @@ describe("Functions module weatherforecast", function () {
|
|||||||
it(`returns correct icons with sunset time`, function () {
|
it(`returns correct icons with sunset time`, function () {
|
||||||
Module.definitions.weatherforecast.processWeather(data.withSunset, moment);
|
Module.definitions.weatherforecast.processWeather(data.withSunset, moment);
|
||||||
let forecastData = Module.definitions.weatherforecast.forecast;
|
let forecastData = Module.definitions.weatherforecast.forecast;
|
||||||
expect(forecastData.length).to.equal(4);
|
expect(forecastData.length).toBe(4);
|
||||||
expect(forecastData[2].icon).to.equal("wi-rain");
|
expect(forecastData[2].icon).toBe("wi-rain");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -104,8 +103,8 @@ describe("Functions module weatherforecast", function () {
|
|||||||
it(`returns correct icons with out sunset time`, function () {
|
it(`returns correct icons with out sunset time`, function () {
|
||||||
Module.definitions.weatherforecast.processWeather(data.withoutSunset, moment);
|
Module.definitions.weatherforecast.processWeather(data.withoutSunset, moment);
|
||||||
let forecastData = Module.definitions.weatherforecast.forecast;
|
let forecastData = Module.definitions.weatherforecast.forecast;
|
||||||
expect(forecastData.length).to.equal(4);
|
expect(forecastData.length).toBe(4);
|
||||||
expect(forecastData[2].icon).to.equal("wi-rain");
|
expect(forecastData[2].icon).toBe("wi-rain");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const expect = require("chai").expect;
|
|
||||||
const vm = require("vm");
|
const vm = require("vm");
|
||||||
|
|
||||||
const basedir = path.join(__dirname, "../../..");
|
const basedir = path.join(__dirname, "../../..");
|
||||||
@ -41,7 +40,7 @@ describe("Default modules set in modules/default/defaultmodules.js", function ()
|
|||||||
|
|
||||||
for (const defaultModule of expectedDefaultModules) {
|
for (const defaultModule of expectedDefaultModules) {
|
||||||
it(`contains a folder for modules/default/${defaultModule}"`, function () {
|
it(`contains a folder for modules/default/${defaultModule}"`, function () {
|
||||||
expect(fs.existsSync(path.join(sandbox.global.root_path, "modules/default", defaultModule))).to.equal(true);
|
expect(fs.existsSync(path.join(sandbox.global.root_path, "modules/default", defaultModule))).toBe(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const expect = require("chai").expect;
|
|
||||||
const vm = require("vm");
|
const vm = require("vm");
|
||||||
|
|
||||||
beforeAll(function () {
|
beforeAll(function () {
|
||||||
@ -45,20 +44,20 @@ describe("'global.root_path' set in js/app.js", function () {
|
|||||||
|
|
||||||
expectedSubPaths.forEach((subpath) => {
|
expectedSubPaths.forEach((subpath) => {
|
||||||
it(`contains a file/folder "${subpath}"`, function () {
|
it(`contains a file/folder "${subpath}"`, function () {
|
||||||
expect(fs.existsSync(path.join(sandbox.global.root_path, subpath))).to.equal(true);
|
expect(fs.existsSync(path.join(sandbox.global.root_path, subpath))).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not modify global.root_path for testing", function () {
|
it("should not modify global.root_path for testing", function () {
|
||||||
expect(global.root_path).to.equal(undefined);
|
expect(global.root_path).toBe(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not modify global.version for testing", function () {
|
it("should not modify global.version for testing", function () {
|
||||||
expect(global.version).to.equal(undefined);
|
expect(global.version).toBe(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should expect the global.version equals package.json file", function () {
|
it("should expect the global.version equals package.json file", function () {
|
||||||
const versionPackage = JSON.parse(fs.readFileSync("package.json", "utf8")).version;
|
const versionPackage = JSON.parse(fs.readFileSync("package.json", "utf8")).version;
|
||||||
expect(sandbox.global.version).to.equal(versionPackage);
|
expect(sandbox.global.version).toBe(versionPackage);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user