Skip to content

Commit

Permalink
Fixes #4. Added tests for 'redirect' and successful response
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydwatkin committed Jun 22, 2013
1 parent 1959250 commit ae8d278
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/lib/pubsub.create.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,23 @@ describe('Publish-Subscribe', function() {
socket.emit('xmpp.pubsub.delete', request)
})

it('Sends redirect element if requested', function(done) {
var request = {
to: 'pubsub.shakespeare.lit',
node: 'twelfth night',
redirect: 'xmpp:pubsub.shakespeare.lit?;node=hamlet'
}
xmpp.once('stanza', function(stanza) {
stanza.getChild('pubsub')
.getChild('delete')
.getChild('redirect')
.attrs.uri
.should.equal(request.redirect)
done()
})
socket.emit('xmpp.pubsub.delete', request)
})

it('Handles an error stanza response', function(done) {
xmpp.once('stanza', function(stanza) {
manager.makeCallback(helper.getStanza('iq-error'))
Expand All @@ -263,5 +280,25 @@ describe('Publish-Subscribe', function() {
)
})

it('Successful response handled ok', function(done) {
xmpp.once('stanza', function(stanza) {
manager.makeCallback(helper.getStanza('iq-result'))
})
var callback = function(error, success) {
should.not.exist(error)
success.should.be.true
done()
}
var request = {
to: 'pubsub.shakespeare.lit',
node: 'twelfth night'
}
socket.emit(
'xmpp.pubsub.delete',
request,
callback
)
})

})
})

0 comments on commit ae8d278

Please sign in to comment.