Skip to content

Commit

Permalink
Merge beeb03f into bebb62b
Browse files Browse the repository at this point in the history
  • Loading branch information
lo1tuma committed Jul 5, 2015
2 parents bebb62b + beeb03f commit d6a417a
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 2 deletions.
1 change: 1 addition & 0 deletions .istanbul.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ instrumentation:
- 'build/**'
embed-source: false
complete-copy: false
include-all-sources: true
reporting:
print: summary
reporty:
Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ node_js:
- "0.10"
- "0.12"
- "iojs"
services:
- mongodb
notifications:
email: false
after_success:
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
"scripts": {
"lint": "eslint .",
"check-coverage": "istanbul check-coverage --statement 100 --branch 100 --function 100 --lines 100",
"test:unit": "istanbul test _mocha test/ -- -R spec --recursive",
"test:unit": "istanbul test _mocha test/unit -- -R spec --recursive",
"test:functional": "mocha test/setupDatabase.js test/functional -R spec --recursive -t 10000",
"pretest": "npm run lint",
"test": "npm run test:unit --coverage",
"test": "npm run test:unit --coverage && npm run test:functional",
"posttest": "npm run check-coverage",
"coveralls": "cat ./build/coverage/lcov.info | coveralls",
"changelog": "pr-log"
Expand All @@ -22,6 +23,7 @@
},
"devDependencies": {
"mocha": "2.2.5",
"mongobox": "0.0.1",
"sinon": "1.15.4",
"sinon-chai": "2.8.0",
"sinon-as-promised": "4.0.0",
Expand Down
4 changes: 4 additions & 0 deletions test/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"mocha": true
},

"globals": {
"MONGOBIRD_TEST_PORT": true
},

"plugins": [ "eslint-plugin-mocha" ],

"rules": {
Expand Down
33 changes: 33 additions & 0 deletions test/functional/simpleIntegrationTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';

var mongobird = require('../../lib/mongobird'),
expect = require('chai').expect;

describe('simple integration test', function () {
var connection,
db,
anyCollection;

beforeEach(function () {
connection = mongobird.connect('mongodb://localhost:' + MONGOBIRD_TEST_PORT);
db = connection.getDb('anyDb');
anyCollection = db.getCollection('anyCollection');
});

it('should count correctly if no document exists', function () {
return anyCollection.count({ anyField: 'anyValue' })
.then(function (count) {
expect(count).to.equal(0);
});
});

it('should count correctly if documents exist', function () {
return anyCollection.insert({ anyField: 'anyValue' })
.then(function () {
return anyCollection.count({ anyField: 'anyValue' });
})
.then(function (count) {
expect(count).to.equal(1);
});
});
});
20 changes: 20 additions & 0 deletions test/setupDatabase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

var MongoBox = require('mongobox').MongoBox,
mongobox = new MongoBox();

before(function (done) {
mongobox.start(function (error) {
if (error) {
return done(error);
}

global.MONGOBIRD_TEST_PORT = mongobox.options.port;

done();
});
});

after(function (done) {
mongobox.stop(done);
});
10 changes: 10 additions & 0 deletions test/unit/mongobirdSpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

var mongobird = require('../../lib/mongobird'),
expect = require('chai').expect;

describe('mongobird', function () {
it('should export the connect method', function () {
expect(mongobird).to.have.property('connect').that.is.a('function');
});
});

0 comments on commit d6a417a

Please sign in to comment.