Skip to content

Commit

Permalink
Merge pull request #94 from vinitkumar/feature/add-jest
Browse files Browse the repository at this point in the history
add tests with mocha, superagent
  • Loading branch information
vinitkumar committed Mar 27, 2017
2 parents e34a3eb + 9119bbb commit b284e9b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -3,3 +3,4 @@ services:
language: node_js
node_js:
- "4.2.4"
script: npm test
3 changes: 3 additions & 0 deletions Makefile
@@ -0,0 +1,3 @@
test:
@./node_modules/.bin/mocha -u tdd --reporter spec
.PHONY: test
8 changes: 5 additions & 3 deletions package.json
Expand Up @@ -6,7 +6,8 @@
"private": false,
"author": "Vinit Kumar <vinit.kumar@changer.nl> (http://vinitkumar.me)",
"scripts": {
"start": "node server.js"
"start": "node server.js",
"test": "make test"
},
"engines": {
"node": "6.3.1"
Expand All @@ -33,10 +34,11 @@
},
"devDependencies": {
"ava": "latest",
"mocha": "^2.4.5",
"jest": "^19.0.2",
"mocha": "^2.5.3",
"nodemon": "latest",
"should": "latest",
"supertest": "latest"
"supertest": "^3.0.0"
},
"subdomain": "ntwitter"
}
1 change: 0 additions & 1 deletion readme.md
Expand Up @@ -14,7 +14,6 @@ You would require Node, NPM and MongoDB installed:
The configuration is in `config/config.js`. Please create your own
github application [Github Developer Settings](https://github.com/settings/applications) and replace the token and keys.


```js
var path = require('path'),
rootPath = path.normalize(__dirname + '/..');
Expand Down
35 changes: 29 additions & 6 deletions test/test.js
@@ -1,11 +1,34 @@
var assert = require('assert');
/* global describe it */

var request = require('supertest');
var app = require('../server');

describe('Array', function () {
describe('#indexOf()', function() {
it('should return -1 when the value is not present', function () {
assert.equal(-1, [1, 2, 3].indexOf(5));
assert.equal(-1, [1, 2, 3].indexOf(4));
describe('Test Homepage', function (done) {
it('should return 302', function (done) {
request(app)
.get('/')
.expect(302, done);
});
});

describe('Test Login', function (done) {
it('should return 200', function (done) {
request(app)
.get('/login')
.expect(200, done);
});
});


describe('Test Login', function (done) {
it('should return 200', function (done) {
request(app)
.get('/apiv1/users')
.expect(200)
.expect('Content-Type', /json/)
.end(function(err, res) {
if (err) return done(err);
done();
});
});
});

0 comments on commit b284e9b

Please sign in to comment.