init tests:

This patch propouse use the mocha for testing MagicMirror.
This commit is contained in:
Rodrigo Ramírez Norambuena 2017-01-15 15:40:23 -03:00
parent a4cb53fdb4
commit 3a8d72db31
3 changed files with 29 additions and 1 deletions

View File

@ -415,3 +415,7 @@ Module.register = function (name, moduleDefinition) {
Log.log("Module registered: " + name); Log.log("Module registered: " + name);
Module.definitions[name] = moduleDefinition; Module.definitions[name] = moduleDefinition;
}; };
exports._test = {
cmpVersions: cmpVersions
}

View File

@ -5,7 +5,8 @@
"main": "js/electron.js", "main": "js/electron.js",
"scripts": { "scripts": {
"start": "electron js/electron.js", "start": "electron js/electron.js",
"postinstall": "sh installers/postinstall/postinstall.sh" "postinstall": "sh installers/postinstall/postinstall.sh",
"test": "./node_modules/mocha/bin/mocha tests --recursive"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -27,12 +28,14 @@
}, },
"homepage": "https://github.com/MichMich/MagicMirror#readme", "homepage": "https://github.com/MichMich/MagicMirror#readme",
"devDependencies": { "devDependencies": {
"chai": "^3.5.0",
"grunt": "latest", "grunt": "latest",
"grunt-eslint": "latest", "grunt-eslint": "latest",
"grunt-jsonlint": "latest", "grunt-jsonlint": "latest",
"grunt-markdownlint": "^1.0.13", "grunt-markdownlint": "^1.0.13",
"grunt-stylelint": "latest", "grunt-stylelint": "latest",
"grunt-yamllint": "latest", "grunt-yamllint": "latest",
"mocha": "^3.2.0",
"stylelint-config-standard": "latest", "stylelint-config-standard": "latest",
"time-grunt": "latest" "time-grunt": "latest"
}, },

View File

@ -0,0 +1,21 @@
var chai = require('chai');
var expect = chai.expect;
var classMM = require('../../js/class.js'); // require for load module.js
var moduleMM = require('../../js/module.js')
describe('Test function cmpVersions into js/module.js', function() {
it('Should be return -1 ', function() {
expect(moduleMM._test.cmpVersions('2.1', '2.2')).to.equal(-1);
});
it('Should be return 0 ', function() {
expect(moduleMM._test.cmpVersions('2.2', '2.2')).to.equal(0);
});
it('Should be return 1', function() {
expect(moduleMM._test.cmpVersions('1.1', '1.0')).to.equal(1);
});
});