From 690567659cc7bbc8d11ae1618c1c0ac67cc1132d Mon Sep 17 00:00:00 2001 From: Sergey Morozov Date: Mon, 23 Jan 2017 09:46:50 -0800 Subject: [PATCH] Minor clean up for test suite @roramirez thanks for starting adding tests. I figured that we might as well grunt them and follow same rules for linting as we do for rest of JS code in the repo. I've made following minor modifications: - added tests to the grunt target - fixed indentation in package.json - made tests a bit more descriptive - fixed eslint errors surfaced by grunt --- Gruntfile.js | 4 ++-- package.json | 2 +- tests/functions/compare-version.js | 21 ++++++++++----------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index ec3128ef..5dca05d9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -7,8 +7,8 @@ module.exports = function(grunt) { configFile: ".eslintrc.json" }, target: ["js/*.js", "modules/default/*.js", "modules/default/*/*.js", - "serveronly/*.js", "*.js", "!modules/default/alert/notificationFx.js", - "!modules/default/alert/modernizr.custom.js", "!modules/default/alert/classie.js" + "serveronly/*.js", "*.js", "tests/*/*.js", "!modules/default/alert/notificationFx.js", + "!modules/default/alert/modernizr.custom.js", "!modules/default/alert/classie.js", ] }, stylelint: { diff --git a/package.json b/package.json index 0cc8f497..4cff0689 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "start": "electron js/electron.js", "postinstall": "sh installers/postinstall/postinstall.sh", - "test": "./node_modules/mocha/bin/mocha tests --recursive" + "test": "./node_modules/mocha/bin/mocha tests --recursive" }, "repository": { "type": "git", diff --git a/tests/functions/compare-version.js b/tests/functions/compare-version.js index 3baaacd0..8cc22101 100644 --- a/tests/functions/compare-version.js +++ b/tests/functions/compare-version.js @@ -1,21 +1,20 @@ -var chai = require('chai'); +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') +var classMM = require("../../js/class.js"); // require for load module.js +var moduleMM = require("../../js/module.js") -describe('Test function cmpVersions in js/module.js', function() { +describe("Test function cmpVersions in js/module.js", function() { - it('Should be return -1 ', function() { - expect(moduleMM._test.cmpVersions('2.1', '2.2')).to.equal(-1); + it("should return -1 when comparing 2.1 to 2.2", 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 0 when comparing 2.2 to 2.2", 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); + it("should be return 1 when comparing 1.1 to 1.0", function() { + expect(moduleMM._test.cmpVersions("1.1", "1.0")).to.equal(1); }); - });