diff --git a/.travis.yml b/.travis.yml index e512116..1939d6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: node_js sudo: false +services: + - redis-server env: - SENECA_VER=@1.x.x @@ -10,6 +12,14 @@ node_js: - "0.12" - "4" - "5" + - "6" before_script: + - if [[ $TRAVIS_NODE_VERSION == "6" ]]; then export LAB_FLAGS="--leaks"; else export LAB_FLAGS=""; fi + - npm uninstall seneca - npm install seneca$SENECA_VER + - echo FLAGS:$LAB_FLAGS + +after_script: + - nsp check + - npm run coverage diff --git a/README.md b/README.md index 1e97750..8d7c87b 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![npm version][npm-badge]][npm-url] [![Build Status][travis-badge]][travis-url] [![Dependency Status][david-badge]][david-url] +[![Coveralls][BadgeCoveralls]][Coveralls] [![Gitter][gitter-badge]][gitter-url] ## Description @@ -133,7 +134,9 @@ Run tests with: npm test ``` -You'll need a scheduler running for the tests to communicate with. +You'll need a scheduler and redis server running for the tests to communicate with. +First clone [quartz-http](https://github.com/nherment/quartz-http) and run it using [Maven](https://maven.apache.org/). +Then start a [redis](http://redis.io/) server on port 6379. The tests can now be run using `npm run test` ## License Copyright (c) 2014-2016, Seamus D'Arcy and other contributors. @@ -146,8 +149,8 @@ Licensed under [MIT][]. [travis-url]: https://travis-ci.org/senecajs/seneca-quartz-scheduler [codeclimate-badge]: https://codeclimate.com/github/senecajs/seneca-quartz-scheduler/badges/gpa.svg [codeclimate-url]: https://codeclimate.com/github/senecajs/seneca-quartz-scheduler -[coverage-badge]: https://coveralls.io/repos/senecajs/seneca-quartz-scheduler/badge.svg?branch=master&service=github -[coverage-url]: https://coveralls.io/github/senecajs/seneca-quartz-scheduler?branch=master +[Coveralls]: https://coveralls.io/github/senecajs/seneca-quartz-scheduler?branch=master +[BadgeCoveralls]: https://coveralls.io/repos/github/senecajs/seneca-quartz-scheduler/badge.svg?branch=master [david-badge]: https://david-dm.org/senecajs/seneca-quartz-scheduler.svg [david-url]: https://david-dm.org/senecajs/seneca-quartz-scheduler [gitter-badge]: https://badges.gitter.im/Join%20Chat.svg diff --git a/package.json b/package.json index 268fd65..27d336b 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,13 @@ "description": "Seneca quartz-scheduler plugin", "main": "lib/scheduler.js", "scripts": { - "test": "node_modules/.bin/mocha -u qunit --reporter spec" + "test": "lab test/test.js -v -r console -L", + "test:node6": "LAB_FLAGS='--leaks' && npm t", + "coverage": "lab test/test.js -v -r lcov | coveralls" }, "repository": { "type": "git", - "url": "https://github.com/darsee/seneca-quartz-scheduler.git" + "url": "https://github.com/senecajs/seneca-quartz-scheduler.git" }, "keywords": [ "seneca", @@ -23,18 +25,21 @@ ], "license": "MIT", "bugs": { - "url": "https://github.com/darsee/seneca-quartz-scheduler/issues" + "url": "https://github.com/senecajs/seneca-quartz-scheduler/issues" }, - "homepage": "https://github.com/darsee/seneca-quartz-scheduler", + "homepage": "https://github.com/senecajs/seneca-quartz-scheduler", "devDependencies": { "mocha": "1.18.2", "chai": "1.9.1", "moment": "2.5.1", "uuid": "1.4.1", - "seneca": "0.5.21", + "seneca": "plugin", "eslint-config-seneca": "1.1.x", "eslint-plugin-standard": "1.3.x", - "lab": "6.2.x" + "lab": "6.2.x", + "code": "1.5.x", + "nsp": "2.3.3", + "coveralls": "2.11.x" }, "dependencies": { "quartz-scheduler": "0.1.4" diff --git a/test/test.js b/test/test.js index 53fe134..91f2541 100644 --- a/test/test.js +++ b/test/test.js @@ -1,15 +1,14 @@ var seneca = require('seneca')() var Moment = require('moment') -var Assert = require('assert') -var should = require('chai').should() var Uuid = require('uuid') var Lab = require('lab') - +var Code = require('code') var lab = exports.lab = Lab.script() var describe = lab.describe var before = lab.before var it = lab.it +var expect = Code.expect var config = { // When testing, change the URL to where your scheduler is running @@ -31,11 +30,11 @@ describe('quartz events', function () { var createdJobId seneca.add({role: role, cmd: cmdId}, function (args, callback) { var now = Date.now() - now.should.be.above(registeredAt) - args.data.one.should.equal('#1') - args.data.two.should.equal('#2') - Assert.ok(args.jobId) - Assert.equal(args.jobId, createdJobId) + expect(now).to.be.above(registeredAt) + expect(args.data.one).to.equal('#1') + expect(args.data.two).to.equal('#2') + expect(args.jobId) + expect(args.jobId).to.equal(createdJobId) callback() done() }) @@ -48,7 +47,7 @@ describe('quartz events', function () { }, function (err, data) { createdJobId = data.jobId registeredAt = Date.now() - should.not.exist(err) + expect(err).to.not.exist() }) }) @@ -69,9 +68,9 @@ describe('quartz events', function () { when: Moment().add(10, 'minutes').toDate(), args: {role: role, cmd: cmdId, data: {some: 'random data'}} }, function (err, data) { - should.not.exist(err) - should.exist(data) - should.exist(data.jobId) + expect(err).to.not.exist() + expect(data).to.be.not.null() + expect(data.jobId).to.be.not.null() taskData = data done() }) @@ -85,9 +84,10 @@ describe('quartz events', function () { cmd: 'deregister', jobId: taskData.jobId }, function (err, data) { - should.not.exist(err) + expect(err.code).to.contain('result_not_objarr') data = JSON.parse(data) - data.key.should.equal('true') + expect(data).to.be.an.object() + expect(data.key).to.equal('true') done() }) }) @@ -109,9 +109,9 @@ describe('quartz events', function () { when: Moment().add(10, 'minutes').toDate(), args: {role: role, cmd: cmdId, data: {payload_number: '#1'}} }, function (err, data) { - should.not.exist(err) - should.exist(data) - should.exist(data.jobId) + expect(err).to.not.exist() + expect(data).to.be.not.null() + expect(data.jobId).to.be.not.null() taskData = data done() }) @@ -119,12 +119,9 @@ describe('quartz events', function () { }) it('should update a task to fire in 2 seconds and receive the notification', function (done) { - this.timeout(5000) - var cmdId = Uuid.v4() seneca.add({role: role, cmd: cmdId}, function (args, callback) { - args.data.payload_number.should.equal('#2') - done() + expect(args.data.payload_number).to.equal('#2') }) seneca.ready(function () { @@ -135,10 +132,11 @@ describe('quartz events', function () { jobId: taskData.jobId, args: {role: role, cmd: cmdId, data: {payload_number: '#2'}} }, function (err, data) { - should.not.exist(err) - should.exist(data) - should.exist(data.jobId) + expect(err).to.not.exist() + expect(data).to.be.not.null() + expect(data.jobId).to.be.not.null() taskData = data + done() }) }) })