Skip to content

Commit

Permalink
test: enabling unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Harley committed Nov 9, 2017
1 parent aa95f69 commit d881a8a
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions test/presence/presence-handlerSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe.only('Presence handler', () => {
services.verify()
})

it.skip('validates parameters on subscribe, unsubscribe and getAll', () => {
it('validates parameters on subscribe, unsubscribe and getAll', () => {
expect(presenceHandler.subscribe.bind(presenceHandler)).to.throw()
expect(presenceHandler.subscribe.bind(presenceHandler, 'name')).to.throw()
expect(presenceHandler.subscribe.bind(presenceHandler, 'name', 123)).to.throw()
Expand All @@ -41,7 +41,6 @@ describe.only('Presence handler', () => {
expect(presenceHandler.subscribe.bind(presenceHandler, null, () => {})).to.throw()
expect(presenceHandler.subscribe.bind(presenceHandler, undefined, () => {})).to.throw()

expect(presenceHandler.unsubscribe.bind(presenceHandler)).to.throw()
expect(presenceHandler.unsubscribe.bind(presenceHandler, '')).to.throw()
expect(presenceHandler.unsubscribe.bind(presenceHandler, 123)).to.throw()
expect(presenceHandler.unsubscribe.bind(presenceHandler, null)).to.throw()
Expand Down Expand Up @@ -99,17 +98,15 @@ describe.only('Presence handler', () => {
await BBPromise.delay(flushTimeout)
})

it.skip('subscribes to presence for all users', async () => {
const userA = 'userA'
it('subscribes to presence for all users', async () => {
const message = {
topic: TOPIC.PRESENCE,
action: PRESENCE_ACTIONS.SUBSCRIBE_ALL,
correlationId: counter.toString()
action: PRESENCE_ACTIONS.SUBSCRIBE_ALL
}
services.connectionMock
.expects('sendMessage')
.once()
.withExactArgs(message)
.withExactArgs(message)
services.timeoutRegistryMock
.expects('add')
.once()
Expand Down Expand Up @@ -139,7 +136,7 @@ describe.only('Presence handler', () => {
presenceHandler.getAll(users, callbackSpy)
})

it.skip('queries for all users presence', () => {
it('queries for all users presence', () => {
const message = {
topic: TOPIC.PRESENCE,
action: PRESENCE_ACTIONS.QUERY_ALL
Expand All @@ -156,29 +153,38 @@ describe.only('Presence handler', () => {
presenceHandler.getAll(callbackSpy)
})

it.skip('sends unsubscribe for specific user presence', async () => {
it('sends unsubscribe for specific user presence', async () => {
const user = 'user'
const subMsg = { topic: TOPIC.PRESENCE, action: PRESENCE_ACTIONS.SUBSCRIBE, correlationId: counter.toString(), parsedData: [ user ] }
counter++
const unsubMsg = { topic: TOPIC.PRESENCE, action: PRESENCE_ACTIONS.UNSUBSCRIBE, correlationId: counter.toString(), parsedData: [ user ] }

services.connectionMock
.expects('sendMessage')
.once()
.withExactArgs(subMsg)
services.timeoutRegistryMock
.expects('add')
.once()
.withExactArgs({ message: subMsg })

presenceHandler.subscribe(user, callbackSpy)
const message = {
topic: TOPIC.PRESENCE,
action: PRESENCE_ACTIONS.UNSUBSCRIBE,
correlationId: counter.toString(),
parsedData: user
}
await BBPromise.delay(100)

services.connectionMock
.expects('sendMessage')
.once()
.withExactArgs(message)
.withExactArgs(unsubMsg)
services.timeoutRegistryMock
.expects('add')
.once()
.withExactArgs({ message })
.withExactArgs({ message: unsubMsg })

presenceHandler.unsubscribe(user)
await BBPromise.delay(flushTimeout)
await BBPromise.delay(100)
})

it.skip('sends unsubscribe for all users presence', async () => {
it.only('sends unsubscribe for all users presence', async () => {
presenceHandler.subscribe(callbackSpy)
const message = {
topic: TOPIC.PRESENCE,
Expand Down

0 comments on commit d881a8a

Please sign in to comment.