3 var assert = require('assert');
4 var ObjectID = require('mongodb').ObjectID;
5 var roomRemovedUserCore = require('../lib/room-removed-user-core');
6 var TroupeRemovedUser = require('gitter-web-persistence').TroupeRemovedUser;
8 describe('room-removed-users-core', function() {
9 describe('addRemovedUser', function() {
10 it('should record a removed user', function() {
11 var userId = new ObjectID();
12 var roomId = new ObjectID();
14 return roomRemovedUserCore
15 .addRemovedUser(roomId, userId)
17 return TroupeRemovedUser.findOne({ troupeId: roomId, userId: userId })
21 .then(function(result) {
23 assert(Date.now() - result.date > 0);
24 assert(Date.now() - result.date < 1000);
25 assert.equal(String(result.userId), String(userId));
26 assert.equal(String(result.troupeId), String(roomId));
31 describe('addRemovedUsers', function() {
32 it('should record removed users', function() {
33 var userId1 = new ObjectID();
34 var userId2 = new ObjectID();
35 var roomId = new ObjectID();
37 return roomRemovedUserCore
38 .addRemovedUsers(roomId, [userId1, userId2])
40 return TroupeRemovedUser.findOne({ troupeId: roomId, userId: userId1 })
44 .then(function(result) {
46 assert(Date.now() - result.date > 0);
47 assert(Date.now() - result.date < 1000);
48 assert.equal(String(result.userId), String(userId1));
49 assert.equal(String(result.troupeId), String(roomId));
51 return TroupeRemovedUser.findOne({ troupeId: roomId, userId: userId1 })
55 .then(function(result) {
57 assert(Date.now() - result.date > 0);
58 assert(Date.now() - result.date < 1000);
59 assert.equal(String(result.userId), String(userId1));
60 assert.equal(String(result.troupeId), String(roomId));