mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
Merge remote-tracking branch 'roramirez_github/develop' into use-before-after-vendors
This commit is contained in:
@@ -50,7 +50,7 @@ describe("Electron app environment", function() {
|
||||
.should.eventually.have.property("height")
|
||||
.and.be.above(0)
|
||||
.browserWindow.getTitle()
|
||||
.should.eventually.equal("Magic Mirror");
|
||||
.should.eventually.equal("MagicMirror²");
|
||||
});
|
||||
|
||||
it("get request from http://localhost:8080 should return 200", function(done) {
|
||||
|
@@ -14,8 +14,10 @@ describe("Functions into modules/default/calendar/calendar.js", function() {
|
||||
Module.definitions[name] = moduleDefinition;
|
||||
};
|
||||
|
||||
// load calendar.js
|
||||
require("../../../modules/default/calendar/calendar.js");
|
||||
before(function() {
|
||||
// load calendar.js
|
||||
require("../../../modules/default/calendar/calendar.js");
|
||||
});
|
||||
|
||||
describe("capFirst", function() {
|
||||
words = {
|
||||
@@ -27,10 +29,47 @@ describe("Functions into modules/default/calendar/calendar.js", function() {
|
||||
};
|
||||
|
||||
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]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("shorten", function() {
|
||||
strings = {
|
||||
" String with whitespace at the beginning that needs trimming" : { length: 16, return: "String with whit…" },
|
||||
"long string that needs shortening": { length: 16, return: "long string that…" },
|
||||
"short string": { length: 16, return: "short string" },
|
||||
"long string with no maxLength defined": { return: "long string with no maxLength defined" },
|
||||
};
|
||||
|
||||
Object.keys(strings).forEach(string => {
|
||||
it(`for '${string}' should return '${strings[string].return}'`, function() {
|
||||
expect(Module.definitions.calendar.shorten(string, strings[string].length)).to.equal(strings[string].return);
|
||||
});
|
||||
});
|
||||
|
||||
it("should return an empty string if shorten is called with a non-string", function () {
|
||||
expect(Module.definitions.calendar.shorten(100)).to.equal("");
|
||||
});
|
||||
|
||||
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");
|
||||
});
|
||||
|
||||
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("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 () {
|
||||
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("This is a wrapEvent <br>test. Should wrap the string <br>instead of shorten it if called <br>with wrapEvent = true");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
37
tests/unit/functions/newsfeed_spec.js
Normal file
37
tests/unit/functions/newsfeed_spec.js
Normal file
@@ -0,0 +1,37 @@
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
var chai = require("chai");
|
||||
var expect = chai.expect;
|
||||
var vm = require("vm");
|
||||
|
||||
|
||||
describe("Functions into modules/default/newsfeed/newsfeed.js", function() {
|
||||
|
||||
Module = {}
|
||||
Module.definitions = {};
|
||||
Module.register = function (name, moduleDefinition) {
|
||||
Module.definitions[name] = moduleDefinition;
|
||||
};
|
||||
|
||||
// load newsfeed.js
|
||||
require("../../../modules/default/newsfeed/newsfeed.js");
|
||||
|
||||
describe("capitalizeFirstLetter", function() {
|
||||
words = {
|
||||
"rodrigo": "Rodrigo",
|
||||
"123m": "123m",
|
||||
"magic mirror": "Magic mirror",
|
||||
",a": ",a",
|
||||
"ñandú": "Ñandú",
|
||||
".!": ".!"
|
||||
};
|
||||
|
||||
Object.keys(words).forEach(word => {
|
||||
it(`for ${word} should return ${words[word]}`, function() {
|
||||
expect(Module.definitions.newsfeed.capitalizeFirstLetter(word)).to.equal(words[word]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user