Created
January 11, 2015 01:56
-
-
Save juanpabloaj/9cf7186eaa43b3c2d6f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('supertest'); | |
var app = require('../server').app; | |
var should = require('should'); | |
describe('GET /api', function(){ | |
it('mensaje de bienvenida en json', function(done){ | |
request(app) | |
.get('/api') | |
.set('Accept', 'application/json') | |
.expect('Content-Type', /json/) | |
.expect(200, done); | |
}); | |
it('mensaje de bienvenida debe "bienvenido"', function(done){ | |
request(app) | |
.get('/api') | |
.expect(200) | |
.end(function(err, res){ | |
res.body.message.should.match(/bienvenido/); | |
done(); | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express(); | |
module.exports.app = app; | |
var site = express.Router(); | |
var port = process.env.PORT || 8080; | |
site.use(function(req, res, next){ | |
next(); | |
}); | |
site.route('/') | |
.get(function(req, res){ | |
res.send('hola js meetup!'); | |
}); | |
site.route('/api') | |
.get(function(req, res){ | |
res.json({message:'bienvenido a la API!'}); | |
}); | |
app.use('/', site); | |
app.listen(port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment