Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added testing with Node@6 #4

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
language: node_js
sudo: false
services:
- redis-server

env:
- [email protected]
Expand All @@ -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
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down
44 changes: 21 additions & 23 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()
})
Expand All @@ -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()
})
})

Expand All @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect to be not null or something

expect(data.jobId)
taskData = data
done()
})
Expand All @@ -85,9 +84,9 @@ describe('quartz events', function () {
cmd: 'deregister',
jobId: taskData.jobId
}, function (err, data) {
should.not.exist(err)
expect(err.code).to.contain('result_not_objarr')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to be different than the original code

data = JSON.parse(data)
data.key.should.equal('true')
expect(data.key).to.equal('true')
done()
})
})
Expand All @@ -109,21 +108,19 @@ 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

expect(data.jobId)
taskData = data
done()
})
})
})

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')
expect(args.data.payload_number).to.equal('#2')
done()
})

Expand All @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

expect(data.jobId)
taskData = data
done()
})
})
})
Expand Down