From 5674a2e8c9ea2e8e36bf3860ba6d9bebcfc1a428 Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Sat, 21 Jan 2017 11:30:26 +0000 Subject: [PATCH 1/2] Replace grunt with npm scripts --- .jshintrc | 2 ++ Gruntfile.js | 41 ----------------------------- package.json | 12 +++++---- test/integration/app-test.js | 4 --- test/integration/email-test.js | 3 --- test/integration/mongo-test.js | 3 --- test/integration/public-key-test.js | 4 --- test/mocha.opts | 2 ++ test/setup.js | 9 +++++++ test/unit/email-test.js | 5 ---- test/unit/pgp-test.js | 2 -- test/unit/util-test.js | 1 - 12 files changed, 20 insertions(+), 68 deletions(-) delete mode 100644 Gruntfile.js create mode 100644 test/mocha.opts create mode 100644 test/setup.js diff --git a/.jshintrc b/.jshintrc index acc3c51..598d3c1 100644 --- a/.jshintrc +++ b/.jshintrc @@ -15,6 +15,8 @@ "esnext": true, "globals": { + "expect": true, + "sinon": true, "describe" : true, "it" : true, "before" : true, diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index 985e5cc..0000000 --- a/Gruntfile.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; - -module.exports = function(grunt) { - - grunt.initConfig({ - jshint: { - all: ['*.js', 'src/**/*.js', 'test/**/*.js'], - options: { - jshintrc: '.jshintrc' - } - }, - - jscs: { - src: ['*.js', 'src/**/*.js', 'test/**/*.js'], - options: { - config: ".jscsrc" - } - }, - - mochaTest: { - test: { - options: { - reporter: 'spec' - }, - src: [ - 'test/unit/*.js', - 'test/integration/*.js', - ] - } - } - }); - - // Load the plugin(s) - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-jscs'); - grunt.loadNpmTasks('grunt-mocha-test'); - - // Default task(s). - grunt.registerTask('test', ['jshint', 'jscs', 'mochaTest']); - -}; \ No newline at end of file diff --git a/package.json b/package.json index 6b999f7..5f93dc9 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,11 @@ }, "scripts": { "start": ": ${NODE_ENV=development} && node index.js", - "test": ": ${NODE_ENV=development} && grunt test" + "test": ": ${NODE_ENV=development} && npm run test:jshint && npm run test:jscs && npm run test:unit && npm run test:integration", + "test:jshint": "jshint *.js src/**/*.js test/**/*.js", + "test:jscs": "jscs *.js src/**/*.js test/**/*.js", + "test:unit": "mocha --opts test/mocha.opts ./test/unit/", + "test:integration": "mocha --opts test/mocha.opts ./test/integration" }, "dependencies": { "addressparser": "^1.0.1", @@ -30,10 +34,8 @@ "devDependencies": { "chai": "^3.5.0", "co-mocha": "^1.1.2", - "grunt": "^1.0.1", - "grunt-contrib-jshint": "^1.0.0", - "grunt-jscs": "^3.0.1", - "grunt-mocha-test": "^0.13.2", + "jscs": "^3.0.7", + "jshint": "^2.9.4", "mocha": "^3.2.0", "sinon": "^1.17.4", "supertest": "^2.0.1" diff --git a/test/integration/app-test.js b/test/integration/app-test.js index e87fb47..7615287 100644 --- a/test/integration/app-test.js +++ b/test/integration/app-test.js @@ -1,14 +1,10 @@ 'use strict'; -require('co-mocha')(require('mocha')); // monkey patch mocha for generators - const request = require('supertest'); const Mongo = require('../../src/dao/mongo'); const nodemailer = require('nodemailer'); const config = require('config'); const fs = require('fs'); -const expect = require('chai').expect; -const sinon = require('sinon'); describe('Koa App (HTTP Server) Integration Tests', function() { this.timeout(20000); diff --git a/test/integration/email-test.js b/test/integration/email-test.js index bab0319..2b0101b 100644 --- a/test/integration/email-test.js +++ b/test/integration/email-test.js @@ -1,8 +1,5 @@ 'use strict'; -require('co-mocha')(require('mocha')); // monkey patch mocha for generators - -const expect = require('chai').expect; const config = require('config'); const Email = require('../../src/email/email'); const tpl = require('../../src/email/templates.json'); diff --git a/test/integration/mongo-test.js b/test/integration/mongo-test.js index e7a7316..b7254c8 100644 --- a/test/integration/mongo-test.js +++ b/test/integration/mongo-test.js @@ -1,10 +1,7 @@ 'use strict'; -require('co-mocha')(require('mocha')); // monkey patch mocha for generators - const config = require('config'); const Mongo = require('../../src/dao/mongo'); -const expect = require('chai').expect; describe('Mongo Integration Tests', function() { this.timeout(20000); diff --git a/test/integration/public-key-test.js b/test/integration/public-key-test.js index 6f27bfc..a682f11 100644 --- a/test/integration/public-key-test.js +++ b/test/integration/public-key-test.js @@ -1,15 +1,11 @@ 'use strict'; -require('co-mocha')(require('mocha')); // monkey patch mocha for generators - const config = require('config'); const nodemailer = require('nodemailer'); const Email = require('../../src/email/email'); const Mongo = require('../../src/dao/mongo'); const PGP = require('../../src/service/pgp'); const PublicKey = require('../../src/service/public-key'); -const expect = require('chai').expect; -const sinon = require('sinon'); describe('Public Key Integration Tests', function() { this.timeout(20000); diff --git a/test/mocha.opts b/test/mocha.opts new file mode 100644 index 0000000..b43dd66 --- /dev/null +++ b/test/mocha.opts @@ -0,0 +1,2 @@ +--recursive +-r ./test/setup.js diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..31e9669 --- /dev/null +++ b/test/setup.js @@ -0,0 +1,9 @@ +'use strict'; + +require('co-mocha')(require('mocha')); // monkey patch mocha for generators + +const expect = require('chai').expect; +const sinon = require('sinon'); + +global.expect = expect; +global.sinon = sinon; diff --git a/test/unit/email-test.js b/test/unit/email-test.js index 0e88a42..5905787 100644 --- a/test/unit/email-test.js +++ b/test/unit/email-test.js @@ -1,13 +1,8 @@ 'use strict'; -require('co-mocha')(require('mocha')); // monkey patch mocha for generators - -const expect = require('chai').expect; const log = require('npmlog'); const Email = require('../../src/email/email'); const nodemailer = require('nodemailer'); -const sinon = require('sinon'); - describe('Email Unit Tests', () => { let email, sendFnStub; diff --git a/test/unit/pgp-test.js b/test/unit/pgp-test.js index d4b31c1..e56a5e3 100644 --- a/test/unit/pgp-test.js +++ b/test/unit/pgp-test.js @@ -1,11 +1,9 @@ 'use strict'; const fs = require('fs'); -const expect = require('chai').expect; const log = require('npmlog'); const openpgp = require('openpgp'); const PGP = require('../../src/service/pgp'); -const sinon = require('sinon'); describe('PGP Unit Tests', () => { let pgp, key1Armored, key2Armored, key3Armored; diff --git a/test/unit/util-test.js b/test/unit/util-test.js index ec7a5ee..7f989d7 100644 --- a/test/unit/util-test.js +++ b/test/unit/util-test.js @@ -1,6 +1,5 @@ 'use strict'; -const expect = require('chai').expect; const util = require('../../src/service/util'); describe('Util Unit Tests', () => { From cb37c834d8e44f8dcf398904d27a16d4ff2d0b11 Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Sat, 21 Jan 2017 12:16:03 +0000 Subject: [PATCH 2/2] Remove grunt from travis.yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e4d9c61..356d933 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ node_js: - "6" - "7" before_script: - - npm install -g grunt-cli - mongo test_db --eval 'db.addUser("travis", "test");' notifications: email: