var request = require('request');
var assert = require('assert');
var http = require('http');
var app = require('../app');
var api = app.get('api');

var server = http.createServer(app);
var port = 3001;
var url = 'http://localhost:' + port + '/api/users';
var srvUser = {
  id: 1234,
  name: 'user 1',
  emain: 'name1@my.com'
};

describe('REST API for /users', function(){
  before (function(done){
    api.data.users = [srvUser];

    server.listen(port, done);
  });

  after (function(done){
    server.close(done);
  });

  it ('should return list of users', function(done) {
    request.get({url:url, json:true}, function(err, res, body){
      // console.log(body);
      assert.equal(1, body.length);
      var user = body[0];
      assert.ok(user);
      assert.equal(srvUser.name, user.name);
      assert.equal(srvUser.id, user.id);
      assert.equal(srvUser.email, user.email);
      done();
    });

  });

});

@@ -324,16 +324,91 @@
 om'%0A%7D;%0A%0A
+var srvUser2 = %7B%0A  id: 2234,%0A  name: 'user 2',%0A  emain: 'name2@my.com'%0A%7D;%0A%0A
 describe
@@ -498,16 +498,26 @@
 %5BsrvUser
+, srvUser2
 %5D;%0A%0A    
@@ -771,17 +771,17 @@
 t.equal(
-1
+2
 , body.l
@@ -1000,12 +1000,341 @@
 %0A  %7D);%0A%0A
+  it ('should get user by id', function(done)%7B%0A%0A    request.get(%7Burl:url+'/1234', json:true%7D, function(err, res, body)%7B%0A      var user = body;%0A      assert.ok(user);%0A      assert.equal(srvUser.name, user.name);%0A      assert.equal(srvUser.id, user.id);%0A      assert.equal(srvUser.email, user.email);%0A      done();%0A    %7D);%0A%0A  %7D);%0A%0A
 %7D);%0A

test for get user by id