Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelKurowski committed Oct 19, 2019
1 parent 346862d commit 5e5bdb5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/server/.tests/mocha/ws-routes/controllers/Room.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ describe('Room websocket namespace', () => {
})

describe('#message', () => {
it.only('should emit message event type on socket when receiving a message event from client', done => {
it('should emit message event type on socket when receiving a message event from client', done => {
//given
const requestMock = {
roomId: 'random room id',
Expand Down Expand Up @@ -312,7 +312,7 @@ describe('Room websocket namespace', () => {
suite.toSpy = sinon.spy(connection, 'to')
connection.on(CLIENT_EVENTS.MESSAGE, data => {
suite.roomInstance.message(data, connection, suite.connectionsMock)
then()
.then(then)
})
})

Expand Down Expand Up @@ -340,7 +340,7 @@ describe('Room websocket namespace', () => {
suite.emitSpy = sinon.spy(connection, 'emit')
connection.on(CLIENT_EVENTS.MESSAGE, data => {
suite.roomInstance.message(data, connection, suite.connectionsMock)
then()
.then(then)
})
})

Expand Down Expand Up @@ -373,7 +373,7 @@ describe('Room websocket namespace', () => {
suite.leaveSpy = sinon.spy(connection, 'leave')
connection.on(CLIENT_EVENTS.MESSAGE, data => {
suite.roomInstance.leave(data, connection, suite.connectionsMock)
then()
.then(then)
})
})

Expand All @@ -384,8 +384,7 @@ describe('Room websocket namespace', () => {

//then
function then() {
const expectedEventData = {roomId: ROOM_ID}
sinon.assert.calledWith(suite.leaveSpy.firstCall, expectedEventData)
sinon.assert.calledWith(suite.leaveSpy.firstCall, ROOM_ID)
done()
}
})
Expand Down Expand Up @@ -650,7 +649,8 @@ describe('Room websocket namespace', () => {
})

function then(data) {
const EXPECTED_USERNAMES = [USER_A_USERNAME, USER_B_USERNAME]
const DUMMY_USERNAME = 'DUMMY_USERNAME'
const EXPECTED_USERNAMES = [USER_A_USERNAME, USER_B_USERNAME, DUMMY_USERNAME]
assert.deepEqual(data.payload.usernames, EXPECTED_USERNAMES)
done()
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/ws-routes/controllers/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class Room {
socket.emit(EVENT_TYPES.LEAVE, response.serialize())
socket.to(roomId).emit(EVENT_TYPES.LEAVE, response.serialize())
socket.leave(roomId)
RoomModel.findOne({id: roomId}, 'members').exec()
return RoomModel.findOne({id: roomId}, 'members').exec()
.then(room => {
room.members = room.members.filter(member => member !== username)
return room.save()
Expand Down

0 comments on commit 5e5bdb5

Please sign in to comment.