Skip to content

Commit

Permalink
Update: Switch to mocha + expect for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Jun 11, 2016
1 parent 31244d4 commit 70b2132
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,22 @@
"node-version.js"
],
"scripts": {
"lint": "eslint . && jscs *.js test/",
"test": "lab -cv"
"lint": "eslint . && jscs index.js node-version.js test/",
"pretest": "npm run lint",
"test": "mocha --async-only",
"cover": "istanbul cover _mocha --report lcovonly",
"coveralls": "npm run cover && istanbul-coveralls"
},
"dependencies": {},
"devDependencies": {
"code": "^1.4.0",
"eslint": "^1.7.3",
"eslint-config-gulp": "^2.0.0",
"expect": "^1.19.0",
"istanbul": "^0.4.3",
"istanbul-coveralls": "^1.0.3",
"jscs": "^2.4.0",
"jscs-preset-gulp": "^1.0.0",
"lab": "^5.5.1"
"mocha": "^2.4.5"
},
"keywords": [
"resolution",
Expand Down
41 changes: 20 additions & 21 deletions test/default-resolution.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,61 @@
'use strict';

var lab = exports.lab = require('lab').script();
var code = require('code');
var expect = require('expect');

var defaultResolution = require('../');
var nodeVersion = require('../node-version');

lab.describe('nodeVersion', function() {
describe('nodeVersion', function() {

lab.it('has all integers and not strings', function(done) {
code.expect(nodeVersion.major).to.be.a.number();
code.expect(nodeVersion.minor).to.be.a.number();
code.expect(nodeVersion.patch).to.be.a.number();
it('has all integers and not strings', function(done) {
expect(nodeVersion.major).toBeA('number');
expect(nodeVersion.minor).toBeA('number');
expect(nodeVersion.patch).toBeA('number');
done();
});
});

lab.describe('defaultResolution', function() {
describe('defaultResolution', function() {
// Typically I don't unit test helpers, but this reduces the last run tests
var major = nodeVersion.major;
var minor = nodeVersion.minor;

lab.afterEach(function(done) {
afterEach(function(done) {
nodeVersion.major = major;
nodeVersion.minor = minor;
done();
});

lab.it('should return default resolution to 1000 (1 second) on node v0.10', function(done) {
it('should return default resolution to 1000 (1 second) on node v0.10', function(done) {
nodeVersion.major = 0;
nodeVersion.minor = 10;
code.expect(defaultResolution()).to.equal(1000);
expect(defaultResolution()).toEqual(1000);
done();
});

lab.it('should return default resolution to 1 (millisecond) on node v0.11', function(done) {
it('should return default resolution to 1 (millisecond) on node v0.11', function(done) {
nodeVersion.major = 0;
nodeVersion.minor = 11;
code.expect(defaultResolution()).to.equal(1);
expect(defaultResolution()).toEqual(1);
done();
});

lab.it('should return default resolution to 1 (millisecond) on node v0.12', function(done) {
it('should return default resolution to 1 (millisecond) on node v0.12', function(done) {
nodeVersion.major = 0;
nodeVersion.minor = 12;
code.expect(defaultResolution()).to.equal(1);
expect(defaultResolution()).toEqual(1);
done();
});

lab.it('should return default resolution to 1 (millisecond) on iojs v1.5', function(done) {
nodeVersion.major = 1;
nodeVersion.minor = 1;
code.expect(defaultResolution()).to.equal(1);
it('should return default resolution to 1 (millisecond) on node v4.3', function(done) {
nodeVersion.major = 4;
nodeVersion.minor = 3;
expect(defaultResolution()).toEqual(1);
done();
});

lab.it('should return default resolution passed as argument', function(done) {
code.expect(defaultResolution(2000)).to.equal(2000);
it('should return default resolution passed as argument', function(done) {
expect(defaultResolution(2000)).toEqual(2000);
done();
});

Expand Down

0 comments on commit 70b2132

Please sign in to comment.