socket.io-hotel
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -6,3 +6,3 @@ _ = require('underscore') | ||
this.adapter = adpt | ||
this.adapter.rooms_props = [] | ||
this.adapter.rooms_props = adpt.rooms_props || {} | ||
} | ||
@@ -16,3 +16,6 @@ | ||
} | ||
Hotel.prototype.removeRoomProperty = function(roomID,key,clbk){ | ||
delete this.adapter.rooms_props[roomID][key]; | ||
clbk(this.adapter.rooms_props[roomID]) | ||
} | ||
Hotel.prototype.getPropertiesRoom = function(roomID, clbk) { | ||
@@ -34,2 +37,3 @@ clbk(this.adapter.rooms_props[roomID]) | ||
delete this.adapter.rooms[roomID] | ||
delete this.adapter.rooms_props[roomID]; | ||
clbk(true) | ||
@@ -36,0 +40,0 @@ return |
{ | ||
"name": "socket.io-hotel", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "socket.io-hotel is a manager that adds new features and functionalities to socket.io's rooms", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -17,5 +17,10 @@ var test = require('tape'), | ||
room1: ['user1'], | ||
room2:['user1', 'user2'], | ||
room2: ['user1', 'user2'], | ||
emptyRoom: [] | ||
}, | ||
rooms_props: { | ||
room1: {size: "Large", name:"Grand Room",color:"Green"}, | ||
room2: {size: "Small", name: "Mini room"}, | ||
emptyRoom: {size:"Medium"} | ||
}, | ||
sids: { | ||
@@ -33,6 +38,7 @@ 'user1': {'room1': true, 'room2': true}, | ||
test('all general', function(t) { | ||
//List all the rooms | ||
hotel.listRooms(function(rooms) { | ||
t.equal(_.size(rooms), 3, 'there are 3 rooms') | ||
}) | ||
//Get users in room2 | ||
hotel.getUsersRoom('room2', function(users) { | ||
@@ -42,21 +48,47 @@ t.equal(_.size(users), 2, 'there are 2 users in room2') | ||
//Check if room exists | ||
hotel.roomExists('room1', function(res) { | ||
t.equal(res, true, 'room1 exists') | ||
}) | ||
//Get the room Properties | ||
hotel.getPropertiesRoom('room1',function(properties){ | ||
t.equal(_.size(properties),3, 'room 1 has 3 properties') | ||
}) | ||
hotel.removeRoomProperty('room1','color',function(properties){ | ||
t.equal(properties.color,undefined,'color was removed from room 1'); | ||
t.equal(_.size(properties),2, 'room 1 has 2 properties') | ||
}) | ||
//Check if ghostRoom exists | ||
hotel.roomExists('ghostRoom', function(res) { | ||
t.equal(res, false, 'ghost room doesnt exist (yet... .AHAHAH)') | ||
}) | ||
//Delete empty room | ||
hotel.delEmptyRoom('room1', function(res) { | ||
t.equal(res, false, 'room1 is not empty do not delete it') | ||
}) | ||
//Get the room1 Properties | ||
hotel.getPropertiesRoom('room1',function(properties){ | ||
t.equal(_.size(properties),2, 'room 1 is not empty so still has properties') | ||
}) | ||
//Get the emptyroom Properties | ||
hotel.getPropertiesRoom('emptyRoom',function(properties){ | ||
t.equal(_.size(properties),1, 'emptyroom has 1 property') | ||
}) | ||
hotel.delEmptyRoom('emptyRoom', function(res) { | ||
t.equal(res, true, 'emeptyRoom is empty (!), delete it!') | ||
t.equal(res, true, 'emptyRoom is empty (!), delete it!') | ||
hotel.roomExists('emptyRoom', function(res) { | ||
t.equal(res, false, 'empty room does not exist anymore') | ||
}) | ||
hotel.getPropertiesRoom('emptyRoom',function(properties){ | ||
t.equal(properties,undefined,'emptyRoom has no properties anymore'); | ||
}) | ||
}) | ||
t.end() | ||
@@ -68,11 +100,9 @@ }) | ||
hotel.setPropertyRoom('room1', 'prop', 'val', function(_notUsed) { | ||
hotel.setPropertyRoom('room1', 'size', 'Small', function(_notUsed) { | ||
hotel.getPropertiesRoom('room1', function(props){ | ||
t.equal(JSON.stringify({prop: 'val'}), | ||
JSON.stringify(props), 'room has new properties') | ||
t.equal(props.size,'Small', 'room has new properties') | ||
hotel.setPropertyRoom('room1', 'prop', 'val2', function(_notUsed) { | ||
hotel.setPropertyRoom('room1', 'size', 'Large', function(_notUsed) { | ||
hotel.getPropertiesRoom('room1', function(props) { | ||
t.equal(JSON.stringify({prop: 'val2'}), | ||
JSON.stringify(props), 'property updated') | ||
t.equal(props.size,'Large', 'property updated') | ||
}) | ||
@@ -79,0 +109,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6141
128