Skip to content

Commit

Permalink
rebase PR #29 (package-update)
Browse files Browse the repository at this point in the history
correct date() assertion test cases match, notMatch, isValid, isNotValid to use regexp that will pass with any local since date objects when compared against a regexp are converted to strings using the toString() method which will be in the format '{SHORT DAY} {SHORT MONTH} {DD} {YYYY} {HH}:{mm}:{ss} GMT+{OFFSET} ({REGION} Time)' values in the curly brackets are variable allowing the tests to fail or pass depending on the local they are executed against

add after trigger to close the http server used in the httpAgent tests

update mocha development package dependency

update bluebird package dependecy

update lodash package dependency

update sinon package dependency

add .travis.yml for ci test reporting

update stupertest package dependency

update should package dependency
  • Loading branch information
scub45t3v3 authored and Nicolab committed Jan 21, 2019
1 parent 8d7cd4f commit 1002573
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 67 deletions.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: node_js
node_js:
- "6.0"
- "7.0"
- "8.0"
- "9.0"
- "10.0"
- "node"
- "lts/*"
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
},
"bugs": "https://github.com/unitjs/unit.js/issues",
"dependencies": {
"bluebird": "^2.9.9",
"lodash": "^3.7.0",
"bluebird": "^3.5.1",
"lodash": "^4.17.10",
"must": "^0.12.0",
"noder.io": ">= 1.0.0 < 2.0.0",
"should": "^6.0.1",
"sinon": ">= 1.14.1 < 2.0.0",
"supertest": ">= 0.15.0 < 1.0.0"
"should": "^13.2.3",
"sinon": "^6.1.4",
"sinon-test": "^2.2.1",
"supertest": "^3.1.0"
},
"devDependencies": {
"gulp": "^3.8.11",
Expand All @@ -38,9 +39,9 @@
"gulp-replace": "^0.5.3",
"gulp-uglify": "^1.2.0",
"gulp-webpack": "^1.3.2",
"webpack": "^1.8.5",
"mocha": "^2.2.4",
"spawn-rmrf": "^1.0.0"
"mocha": "^5.2.0",
"spawn-rmrf": "^1.0.0",
"webpack": "^1.8.5"
},
"scripts": {
"test": "mocha test"
Expand Down
10 changes: 5 additions & 5 deletions src/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ module.exports = function(actual) {

countAssertion('isArguments', true);

should(actual).arguments;
should(actual).be.Arguments();

return this;
},
Expand All @@ -442,7 +442,7 @@ module.exports = function(actual) {

countAssertion('isNotArguments', true);

should(actual).not.arguments;
should(actual).not.be.Arguments();

return this;
},
Expand Down Expand Up @@ -711,7 +711,7 @@ module.exports = function(actual) {

countAssertion('isApprox', true);

should(actual).approximately(num, delta);
should(actual).be.approximately(num, delta);

return this;
},
Expand All @@ -720,7 +720,7 @@ module.exports = function(actual) {

countAssertion('isInfinite', true);

should(actual).Infinity;
should(actual).be.Infinity();

return this;
},
Expand All @@ -729,7 +729,7 @@ module.exports = function(actual) {

countAssertion('isNotInfinite', true);

should(actual).not.Infinity;
should(actual).not.be.Infinity();

return this;
},
Expand Down
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ var assert = require('./assert');
var should = require('should');
var must = require('must');
var sinon = require('sinon');
var sinonTest = require('sinon-test');
var supertest = require('supertest');

// patch sinon with sinon-test
sinon.test = sinonTest(sinon);

// Populate the root API
api.promise = promise;
api.promisify = promise.promisify;
Expand Down
88 changes: 42 additions & 46 deletions test/node/httpAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,58 +62,54 @@ describe('supertest library to as httpAgent', function() {
server.listen(0);
});

after(function() {
// close the server so that mocha can exit once done running tests
server.close();
});


it('Good request', function() {
it('Good request', function(done) {

var testServer;

test
.given('Create a server asserter', function(){

testServer = function(name){

test.bool(indicator.get(name + '_page')).isFalse();

// async queue
test.promise.resolve()
.then(function(){
return test.httpAgent(server).get('/' + (name == 'home' ? '' : name));
})
.then(function(request){
request
.expect(200, name + ' page')
.expect('x-powered-by', 'unit.js')
.expect('Content-Type', /text/)

.end(function(err, res){
test
.bool(indicator.get(name + '_page'))
.isTrue()

.value(err)
.isFalsy()

.string(res.text)
.isIdenticalTo(name + ' page')
;
})
;
})
.catch(function(err) {
throw err;
})
.done()
;
};
})
test.given('Create a server asserter', function(){

.then('Test the server: "/"', function(){
testServer('home');
})
testServer = function(name){

.then('Test the server: "/some"', function(){
testServer('some');
})
test.bool(indicator.get(name + '_page')).isFalse();

test.httpAgent(server)
.get('/' + (name == 'home' ? '' : name))
.expect(200, name + ' page')
.expect('x-powered-by', 'unit.js')
.expect('Content-Type', /text/)
.end(function(err, res){
test
.bool(indicator.get(name + '_page'))
.isTrue()

.value(err)
.isFalsy()

.string(res.text)
.isIdenticalTo(name + ' page')
;
})
;
};
})

.then('Test the server: "/"', function(){
testServer('home');
})

.then('Test the server: "/some"', function(){
testServer('some');
})

.then('Exit test case', function(){
done();
})
;
});

Expand Down
16 changes: 8 additions & 8 deletions test/src/asserters/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ describe('Asserter date()', function(){

test
.date(date)
.match(/2010/)
.match(/\d/)

.exception(function(){
test.date(date).match(/03/);
test.date(date).match(/^\d$/);
})
;

Expand All @@ -196,10 +196,10 @@ describe('Asserter date()', function(){

test
.date(date)
.notMatch(/03/)
.notMatch(/^\d$/)

.exception(function(){
test.date(date).notMatch(/02/);
test.date(date).notMatch(/\d/);
})
;

Expand All @@ -211,10 +211,10 @@ describe('Asserter date()', function(){

test
.date(date)
.isValid(/2010/)
.isValid(/\d/)

.exception(function(){
test.date(date).isValid(/03/);
test.date(date).isValid(/^\d$/);
})
;

Expand All @@ -226,10 +226,10 @@ describe('Asserter date()', function(){

test
.date(date)
.isNotValid(/03/)
.isNotValid(/^\d$/)

.exception(function(){
test.date(date).isNotValid(/02/);
test.date(date).isNotValid(/\d/);
})
;

Expand Down

0 comments on commit 1002573

Please sign in to comment.