3 var app = require('../..');
4 var User = require('./user.model');
5 var request = require('supertest');
7 describe('User API:', function() {
10 // Clear users before testing
12 return User.removeAsync().then(function() {
15 email: 'test@example.com',
19 return user.saveAsync();
23 // Clear users after testing
25 return User.removeAsync();
28 describe('GET /api/users/me', function() {
31 before(function(done) {
35 email: 'test@example.com',
39 .expect('Content-Type', /json/)
40 .end(function(err, res) {
41 token = res.body.token;
46 it('should respond with a user profile when authenticated', function(done) {
49 .set('authorization', 'Bearer ' + token)
51 .expect('Content-Type', /json/)
52 .end(function(err, res) {
53 res.body._id.toString().should.equal(user._id.toString());
58 it('should respond with a 401 when not authenticated', function(done) {