Skip to content
Browse files

All test files now passing lint tests

  • Loading branch information...
1 parent 720a894 commit e17904f57125b9050562e6bd51aa0a9929cfc9ba @lloydwatkin lloydwatkin committed Dec 20, 2013
View
2 Gruntfile.js
@@ -5,7 +5,7 @@ module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
- allFiles: ['gruntfile.js', 'lib/**/*.js', 'examples/**/*.js'],
+ allFiles: ['gruntfile.js', 'lib/**/*.js', 'test/**/*.js'],
options: {
jshintrc: '.jshintrc',
}
View
5 test/helper.js
@@ -1,3 +1,5 @@
+'use strict';
+
var ltx = require('ltx')
, fs = require('fs')
, Event = require('events').EventEmitter
@@ -15,4 +17,5 @@ Eventer.prototype = new Event()
Eventer.prototype.send = function(stanza) {
this.emit('stanza', stanza.root())
}
-exports.Eventer = Eventer
+
+exports.Eventer = Eventer
View
36 test/lib/chat.js
@@ -1,9 +1,12 @@
+'use strict';
+
var Chat = require('../../index').Chat
, ltx = require('ltx')
, helper = require('../helper')
, should = require('should')
, chatState = require('../../index').utils['xep-0085']
+/* jshint -W030 */
describe('Chat', function() {
var chat
@@ -128,13 +131,13 @@ describe('Chat', function() {
it('https://github.com/lloydwatkin/xmpp-ftw/issues/40', function(done) {
socket.once('xmpp.chat.message', function(data) {
- data.should.eql({
- from: { domain: 'buddycloud.org', user: 'lloyd', resource: '...' },
- content: 'hey',
- format: 'plain',
- state: 'active'
- })
- done()
+ data.should.eql({
+ from: { domain: 'buddycloud.org', user: 'lloyd', resource: '...' },
+ content: 'hey',
+ format: 'plain',
+ state: 'active'
+ })
+ done()
})
chat.handle(helper.getStanza('issues/40')).should.be.true
})
@@ -145,7 +148,7 @@ describe('Chat', function() {
it('Sends error message if \'to\' parameter missing', function(done) {
socket.once('xmpp.error.client', function(data) {
- data.description.should.equal("Missing 'to' key")
+ data.description.should.equal('Missing \'to\' key')
data.type.should.equal('modify')
data.condition.should.equal('client-error')
data.request.should.eql({})
@@ -184,7 +187,7 @@ describe('Chat', function() {
var to = 'romeo@montague.net/orchard'
var content = 'This will <strong>fail'
socket.once('xmpp.error.client', function(data) {
- data.description.should.equal("Can not parse XHTML message")
+ data.description.should.equal('Can not parse XHTML message')
data.type.should.equal('modify')
data.condition.should.equal('client-error')
data.request.to.should.equal(to)
@@ -193,7 +196,9 @@ describe('Chat', function() {
done()
})
chat.sendMessage({
- to: to, content: content, format: chat.XHTML
+ to: to,
+ content: content,
+ format: chat.XHTML
})
})
@@ -216,7 +221,9 @@ describe('Chat', function() {
done()
})
chat.sendMessage({
- to: to, content: content, format: chat.XHTML
+ to: to,
+ content: content,
+ format: chat.XHTML
})
})
@@ -239,7 +246,9 @@ describe('Chat', function() {
done()
})
chat.sendMessage({
- to: to, content: content, format: chat.XHTML
+ to: to,
+ content: content,
+ format: chat.XHTML
})
})
@@ -252,7 +261,8 @@ describe('Chat', function() {
done()
})
chat.sendMessage({
- to: to, state: state
+ to: to,
+ state: state
})
})
View
78 test/lib/presence.js
@@ -1,8 +1,11 @@
+'use strict';
+
var should = require('should')
, Presence = require('../../index').Presence
, ltx = require('ltx')
, helper = require('../helper')
+/* jshint -W030 */
describe('Presence', function() {
var presence, socket, xmpp, manager
@@ -95,9 +98,9 @@ describe('Presence', function() {
data.status.should.equal('say hello to me')
data.priority.should.equal('10')
data.show.should.equal('chat')
- done()
+ done()
})
- presence.handle(helper.getStanza('presence/presence-reply'))
+ presence.handle(helper.getStanza('presence/presence-reply'))
})
})
@@ -152,7 +155,7 @@ describe('Presence', function() {
socket.once('xmpp.error.client', function(data) {
data.type.should.equal('modify')
data.condition.should.equal('client-error')
- data.description.should.equal("Missing 'to' key")
+ data.description.should.equal('Missing \'to\' key')
data.request.should.eql({})
xmpp.removeAllListeners('stanza')
done()
@@ -161,16 +164,17 @@ describe('Presence', function() {
})
it('Can send subscribe stanza', function(done) {
- var to = 'juliet@example.com/balcony'
- xmpp.once('stanza', function(stanza) {
- stanza.is('presence').should.be.true
- stanza.attrs.to.should.equal(to)
- stanza.attrs.type.should.equal('subscribe')
- stanza.attrs.from.should.equal(manager.jid)
- done()
- })
- socket.emit('xmpp.presence.subscribe', { to: to })
- })
+ var to = 'juliet@example.com/balcony'
+ xmpp.once('stanza', function(stanza) {
+ stanza.is('presence').should.be.true
+ stanza.attrs.to.should.equal(to)
+ stanza.attrs.type.should.equal('subscribe')
+ stanza.attrs.from.should.equal(manager.jid)
+ done()
+ })
+ socket.emit('xmpp.presence.subscribe', { to: to })
+ }
+ )
})
describe('Subscribed stanzas', function() {
@@ -182,7 +186,7 @@ describe('Presence', function() {
socket.once('xmpp.error.client', function(data) {
data.type.should.equal('modify')
data.condition.should.equal('client-error')
- data.description.should.equal("Missing 'to' key")
+ data.description.should.equal('Missing \'to\' key')
data.request.should.eql({})
xmpp.removeAllListeners('stanza')
done()
@@ -191,16 +195,17 @@ describe('Presence', function() {
})
it('Can send subscribed stanza', function(done) {
- var to = 'juliet@example.com/balcony'
- xmpp.once('stanza', function(stanza) {
- stanza.is('presence').should.be.true
- stanza.attrs.to.should.equal(to)
- stanza.attrs.type.should.equal('subscribed')
- stanza.attrs.from.should.equal(manager.jid)
- done()
- })
- socket.emit('xmpp.presence.subscribed', { to: to })
- })
+ var to = 'juliet@example.com/balcony'
+ xmpp.once('stanza', function(stanza) {
+ stanza.is('presence').should.be.true
+ stanza.attrs.to.should.equal(to)
+ stanza.attrs.type.should.equal('subscribed')
+ stanza.attrs.from.should.equal(manager.jid)
+ done()
+ })
+ socket.emit('xmpp.presence.subscribed', { to: to })
+ }
+ )
})
describe('Unsubscribed stanzas', function() {
@@ -212,7 +217,7 @@ describe('Presence', function() {
socket.once('xmpp.error.client', function(data) {
data.type.should.equal('modify')
data.condition.should.equal('client-error')
- data.description.should.equal("Missing 'to' key")
+ data.description.should.equal('Missing \'to\' key')
data.request.should.eql({})
xmpp.removeAllListeners('stanza')
done()
@@ -221,16 +226,17 @@ describe('Presence', function() {
})
it('Can send unsubscribed stanza', function(done) {
- var to = 'juliet@example.com/balcony'
- xmpp.once('stanza', function(stanza) {
- stanza.is('presence').should.be.true
- stanza.attrs.to.should.equal(to)
- stanza.attrs.type.should.equal('unsubscribed')
- stanza.attrs.from.should.equal(manager.jid)
- done()
- })
- socket.emit('xmpp.presence.unsubscribed', { to: to })
- })
+ var to = 'juliet@example.com/balcony'
+ xmpp.once('stanza', function(stanza) {
+ stanza.is('presence').should.be.true
+ stanza.attrs.to.should.equal(to)
+ stanza.attrs.type.should.equal('unsubscribed')
+ stanza.attrs.from.should.equal(manager.jid)
+ done()
+ })
+ socket.emit('xmpp.presence.unsubscribed', { to: to })
+ }
+ )
})
it('Presence request errors when missing \'to\'', function(done) {
@@ -240,7 +246,7 @@ describe('Presence', function() {
socket.once('xmpp.error.client', function(data) {
data.type.should.equal('modify')
data.condition.should.equal('client-error')
- data.description.should.equal("Missing 'to' key")
+ data.description.should.equal('Missing \'to\' key')
data.request.should.eql({})
xmpp.removeAllListeners('stanza')
done()
View
296 test/lib/roster.js
@@ -1,8 +1,11 @@
+'use strict';
+
var should = require('should')
, Roster = require('../../index').Roster
, ltx = require('ltx')
, helper = require('../helper')
+/* jshint -W030 */
describe('Roster', function() {
var roster, socket, xmpp, manager
@@ -46,7 +49,7 @@ describe('Roster', function() {
roster.handles(request).should.be.true
})
- it("Should return false from 'handle' with non-set stanza", function() {
+ it('Should return false from \'handle\' with non-set stanza', function() {
var request = ltx.parse(
'<iq type="get"><query xmlns="' + roster.NS + '"/></iq>'
)
@@ -87,90 +90,92 @@ describe('Roster', function() {
describe('Can send roster IQ stanzas', function() {
- describe('Add a user to roster', function() {
+ describe('Add a user to roster', function() {
- it('Returns error when no jid provided', function(done) {
+ it('Returns error when no jid provided', function(done) {
xmpp.once('stanza', function() {
done('Unexpected outgoing stanza')
})
socket.emit('xmpp.roster.add', {}, function(error, success) {
should.not.exist(success)
error.type.should.equal('modify')
error.condition.should.equal('client-error')
- error.description.should.equal("Missing 'jid' key")
+ error.description.should.equal('Missing \'jid\' key')
error.request.should.eql({})
xmpp.removeAllListeners('stanza')
done()
})
- })
+ })
- it('Errors when no callback provided', function(done) {
+ it('Errors when no callback provided', function(done) {
xmpp.once('stanza', function() {
done('Unexpected outgoing stanza')
})
socket.once('xmpp.error.client', function(error) {
error.type.should.equal('modify')
error.condition.should.equal('client-error')
- error.description.should.equal("Missing callback")
+ error.description.should.equal('Missing callback')
error.request.should.eql({})
xmpp.removeAllListeners('stanza')
done()
})
socket.emit('xmpp.roster.add', {})
- })
+ })
- it('Errors when non-function callback provided', function(done) {
+ it('Errors when non-function callback provided', function(done) {
xmpp.once('stanza', function() {
done('Unexpected outgoing stanza')
})
socket.once('xmpp.error.client', function(error) {
error.type.should.equal('modify')
error.condition.should.equal('client-error')
- error.description.should.equal("Missing callback")
+ error.description.should.equal('Missing callback')
error.request.should.eql({})
xmpp.removeAllListeners('stanza')
done()
})
socket.emit('xmpp.roster.add', {}, true)
- })
+ })
- it('Sends expected add stanza', function(done) {
+ it('Sends expected add stanza', function(done) {
var jid = 'alice@wonderland.lit'
xmpp.once('stanza', function(stanza) {
- stanza.is('iq').should.be.true
- stanza.attrs.type.should.equal('set')
- should.exist(stanza.attrs.id)
- manager.makeCallback(ltx.parse('<iq type="result" />'))
- })
+ stanza.is('iq').should.be.true
+ stanza.attrs.type.should.equal('set')
+ should.exist(stanza.attrs.id)
+ manager.makeCallback(ltx.parse('<iq type="result" />'))
+ }
+ )
var callback = function(error, success) {
should.not.exist(error)
success.should.be.true
done()
}
socket.emit('xmpp.roster.add', { jid: jid }, callback)
- })
+ })
- it('Can handle roster add with additional data', function(done) {
+ it('Can handle roster add with additional data', function(done) {
var request = {
jid: 'alice@wonderland.lit',
groups: [ 'group1', 'group2' ],
name: 'Alice'
}
xmpp.once('stanza', function(stanza) {
- stanza.is('iq').should.be.true
- stanza.attrs.type.should.equal('set')
- should.exist(stanza.attrs.id)
- var query = stanza.getChild('query', roster.NS)
- var item = query.getChild('item')
- item.attrs.jid.should.equal(request.jid)
- item.attrs.name.should.equal(request.name)
- item.getChildren('group').length.should.equal(2)
- item.getChildren('group')[0].getText()
- .should.equal('group1')
- item.getChildren('group')[1].getText()
- .should.equal('group2')
- manager.makeCallback(ltx.parse('<iq type="result" />'))
- })
+ stanza.is('iq').should.be.true
+ stanza.attrs.type.should.equal('set')
+ should.exist(stanza.attrs.id)
+ var query = stanza.getChild('query', roster.NS)
+ var item = query.getChild('item')
+ item.attrs.jid.should.equal(request.jid)
+ item.attrs.name.should.equal(request.name)
+ item.getChildren('group').length.should.equal(2)
+ item.getChildren('group')[0].getText()
+ .should.equal('group1')
+ item.getChildren('group')[1].getText()
+ .should.equal('group2')
+ manager.makeCallback(ltx.parse('<iq type="result" />'))
+ }
+ )
var callback = function(error, success) {
should.not.exist(error)
success.should.be.true
@@ -182,13 +187,14 @@ describe('Roster', function() {
it('Can handle error response', function(done) {
var jid = 'alice@wonderland.lit'
xmpp.once('stanza', function(stanza) {
- stanza.is('iq').should.be.true
- stanza.attrs.type.should.equal('set')
- should.exist(stanza.attrs.id)
- var query = stanza.getChild('query', roster.NS)
- query.getChild('item').attrs.jid.should.equal(jid)
- manager.makeCallback(helper.getStanza('iq-error'))
- })
+ stanza.is('iq').should.be.true
+ stanza.attrs.type.should.equal('set')
+ should.exist(stanza.attrs.id)
+ var query = stanza.getChild('query', roster.NS)
+ query.getChild('item').attrs.jid.should.equal(jid)
+ manager.makeCallback(helper.getStanza('iq-error'))
+ }
+ )
var callback = function(error, success) {
should.not.exist(success)
error.should.eql({
@@ -206,26 +212,29 @@ describe('Roster', function() {
it('Can get roster', function(done) {
xmpp.once('stanza', function(stanza) {
- stanza.is('iq').should.be.true
- stanza.attrs.type.should.equal('get')
- should.exist(stanza.attrs.id)
- should.not.exist(stanza.attrs.to)
- stanza.attrs.from.should.include(manager.jid)
- should.exist(stanza.getChild('query', roster.NS))
- manager.makeCallback(helper.getStanza('roster/get'))
- })
+ stanza.is('iq').should.be.true
+ stanza.attrs.type.should.equal('get')
+ should.exist(stanza.attrs.id)
+ should.not.exist(stanza.attrs.to)
+ stanza.attrs.from.should.include(manager.jid)
+ should.exist(stanza.getChild('query', roster.NS))
+ manager.makeCallback(helper.getStanza('roster/get'))
+ }
+ )
var callback = function(error, roster) {
should.not.exist(error)
roster.length.should.equal(2)
roster[0].jid.should.eql({
- domain: 'example.net', user: 'juliet'
+ domain: 'example.net',
+ user: 'juliet'
})
roster[0].subscription.should.equal('from')
roster[0].groups.should.eql(['colleagues', 'buddies'])
should.not.exist(roster[0].name)
should.not.exist(roster[0].ask)
roster[1].jid.should.eql({
- domain: 'example.com', user: 'romeo'
+ domain: 'example.com',
+ user: 'romeo'
})
roster[1].subscription.should.equal('none')
roster[1].name.should.equal('Romeo')
@@ -243,7 +252,7 @@ describe('Roster', function() {
socket.once('xmpp.error.client', function(error) {
error.type.should.equal('modify')
error.condition.should.equal('client-error')
- error.description.should.equal("Missing callback")
+ error.description.should.equal('Missing callback')
should.not.exist(error.request)
xmpp.removeAllListeners('stanza')
done()
@@ -258,7 +267,7 @@ describe('Roster', function() {
socket.once('xmpp.error.client', function(error) {
error.type.should.equal('modify')
error.condition.should.equal('client-error')
- error.description.should.equal("Missing callback")
+ error.description.should.equal('Missing callback')
should.not.exist(error.request)
xmpp.removeAllListeners('stanza')
done()
@@ -267,44 +276,45 @@ describe('Roster', function() {
})
it('Can handle error response', function(done) {
- xmpp.once('stanza', function(stanza) {
- stanza.is('iq').should.be.true
- stanza.attrs.type.should.equal('get')
- should.exist(stanza.attrs.id)
- stanza.getChild('query', roster.NS).should.exist
- manager.makeCallback(helper.getStanza('iq-error'))
- })
- var callback = function(error, success) {
- should.not.exist(success)
- error.should.eql({
- type: 'cancel',
- condition: 'error-condition'
+ xmpp.once('stanza', function(stanza) {
+ stanza.is('iq').should.be.true
+ stanza.attrs.type.should.equal('get')
+ should.exist(stanza.attrs.id)
+ stanza.getChild('query', roster.NS).should.exist
+ manager.makeCallback(helper.getStanza('iq-error'))
+ }
+ )
+ var callback = function(error, success) {
+ should.not.exist(success)
+ error.should.eql({
+ type: 'cancel',
+ condition: 'error-condition'
+ })
+ done()
+ }
+ socket.emit('xmpp.roster.get', {}, callback)
})
- done()
- }
- socket.emit('xmpp.roster.get', {}, callback)
- })
})
describe('Edit roster', function() {
- it('Not providing \'jid\' returns error', function(done) {
+ it('Not providing \'jid\' returns error', function(done) {
xmpp.once('stanza', function() {
done('Unexpected outgoing stanza')
})
socket.emit('xmpp.roster.edit', {}, function(error, success) {
should.not.exist(success)
error.type.should.equal('modify')
error.condition.should.equal('client-error')
- error.description.should.equal("Missing 'jid' key")
+ error.description.should.equal('Missing \'jid\' key')
error.request.should.eql({})
xmpp.removeAllListeners('stanza')
done()
})
- })
+ })
- it('Not providing \'groups\' return error', function(done) {
+ it('Not providing \'groups\' return error', function(done) {
xmpp.once('stanza', function() {
done('Unexpected outgoing stanza')
})
@@ -313,14 +323,14 @@ describe('Roster', function() {
should.not.exist(success)
error.type.should.equal('modify')
error.condition.should.equal('client-error')
- error.description.should.equal("Missing 'groups' key")
+ error.description.should.equal('Missing \'groups\' key')
error.request.should.eql(request)
xmpp.removeAllListeners('stanza')
done()
})
- })
+ })
- it('Not passing array for \'groups\' returns error', function(done) {
+ it('Not passing array for \'groups\' returns error', function(done) {
xmpp.once('stanza', function() {
done('Unexpected outgoing stanza')
})
@@ -332,26 +342,26 @@ describe('Roster', function() {
should.not.exist(success)
error.type.should.equal('modify')
error.condition.should.equal('client-error')
- error.description.should.equal("Groups should be an array")
+ error.description.should.equal('Groups should be an array')
error.request.should.eql(request)
xmpp.removeAllListeners('stanza')
done()
})
- })
+ })
- it('Handles error response stanza', function(done) {
+ it('Handles error response stanza', function(done) {
var request = {
jid: 'alice@wonderland.lit',
groups: [ 'group1', 'group2' ]
}
xmpp.once('stanza', function(stanza) {
- stanza.is('iq').should.be.true
- stanza.attrs.type.should.equal('set')
- should.exist(stanza.attrs.id)
- var query = stanza.getChild('query', roster.NS)
- query.getChild('item').attrs.jid.should.equal(request.jid)
- manager.makeCallback(helper.getStanza('iq-error'))
- })
+ stanza.is('iq').should.be.true
+ stanza.attrs.type.should.equal('set')
+ should.exist(stanza.attrs.id)
+ var query = stanza.getChild('query', roster.NS)
+ query.getChild('item').attrs.jid.should.equal(request.jid)
+ manager.makeCallback(helper.getStanza('iq-error'))
+ })
var callback = function(error, success) {
should.not.exist(success)
error.should.eql({
@@ -361,34 +371,34 @@ describe('Roster', function() {
done()
}
socket.emit('xmpp.roster.edit', request, callback)
- })
+ })
- it('Allows the setting of roster groups', function(done) {
+ it('Allows the setting of roster groups', function(done) {
var request = {
jid: 'alice@wonderland.lit',
groups: [ 'group1', 'group2' ]
}
xmpp.once('stanza', function(stanza) {
- stanza.is('iq').should.be.true
- stanza.attrs.type.should.equal('set')
- should.exist(stanza.attrs.id)
- var item = stanza.getChild('query', roster.NS)
- .getChild('item')
- item.attrs.jid.should.equal(request.jid)
- item.getChildren('group').length.should.equal(2)
- item.getChildren('group')[0].getText().should.equal('group1')
- item.getChildren('group')[1].getText().should.equal('group2')
- manager.makeCallback(helper.getStanza('iq-result'))
- })
+ stanza.is('iq').should.be.true
+ stanza.attrs.type.should.equal('set')
+ should.exist(stanza.attrs.id)
+ var item = stanza.getChild('query', roster.NS)
+ .getChild('item')
+ item.attrs.jid.should.equal(request.jid)
+ item.getChildren('group').length.should.equal(2)
+ item.getChildren('group')[0].getText().should.equal('group1')
+ item.getChildren('group')[1].getText().should.equal('group2')
+ manager.makeCallback(helper.getStanza('iq-result'))
+ })
var callback = function(error, success) {
should.not.exist(error)
success.should.be.true
done()
}
socket.emit('xmpp.roster.edit', request, callback)
- })
+ })
- it('Errors when no callback provided', function(done) {
+ it('Errors when no callback provided', function(done) {
var request = {
jid: 'alice@wonderland.lit',
groups: [ 'group1', 'group2' ]
@@ -399,15 +409,15 @@ describe('Roster', function() {
socket.once('xmpp.error.client', function(error) {
error.type.should.equal('modify')
error.condition.should.equal('client-error')
- error.description.should.equal("Missing callback")
+ error.description.should.equal('Missing callback')
error.request.should.eql(request)
xmpp.removeAllListeners('stanza')
done()
})
socket.emit('xmpp.roster.edit', request)
- })
+ })
- it('Errors when non-function callback provided', function(done) {
+ it('Errors when non-function callback provided', function(done) {
var request = {
jid: 'alice@wonderland.lit',
groups: [ 'group1', 'group2' ]
@@ -418,114 +428,114 @@ describe('Roster', function() {
socket.once('xmpp.error.client', function(error) {
error.type.should.equal('modify')
error.condition.should.equal('client-error')
- error.description.should.equal("Missing callback")
+ error.description.should.equal('Missing callback')
error.request.should.eql(request)
xmpp.removeAllListeners('stanza')
done()
})
socket.emit('xmpp.roster.edit', request, true)
- })
+ })
- it('Can handle name field', function(done) {
+ it('Can handle name field', function(done) {
var request = {
jid: 'alice@wonderland.lit',
groups: [],
name: 'Alice'
}
xmpp.once('stanza', function(stanza) {
- stanza.is('iq').should.be.true
- stanza.attrs.type.should.equal('set')
- should.exist(stanza.attrs.id)
- var query = stanza.getChild('query', roster.NS)
- query.getChild('item').attrs.jid.should.equal(request.jid)
- query.getChild('item').attrs.name.should.equal(request.name)
- manager.makeCallback(helper.getStanza('iq-error'))
- done()
- })
+ stanza.is('iq').should.be.true
+ stanza.attrs.type.should.equal('set')
+ should.exist(stanza.attrs.id)
+ var query = stanza.getChild('query', roster.NS)
+ query.getChild('item').attrs.jid.should.equal(request.jid)
+ query.getChild('item').attrs.name.should.equal(request.name)
+ manager.makeCallback(helper.getStanza('iq-error'))
+ done()
+ })
socket.emit('xmpp.roster.edit', request, function() {})
- })
+ })
})
})
describe('Remove a roster item', function() {
- it('Returns error when no jid provided', function(done) {
+ it('Returns error when no jid provided', function(done) {
xmpp.once('stanza', function() {
done('Unexpected outgoing stanza')
})
socket.emit('xmpp.roster.remove', {}, function(error, success) {
should.not.exist(success)
error.type.should.equal('modify')
error.condition.should.equal('client-error')
- error.description.should.equal("Missing 'jid' key")
+ error.description.should.equal('Missing \'jid\' key')
error.request.should.eql({})
xmpp.removeAllListeners('stanza')
done()
})
- })
+ })
- it('Errors when no callback provided', function(done) {
+ it('Errors when no callback provided', function(done) {
xmpp.once('stanza', function() {
done('Unexpected outgoing stanza')
})
socket.once('xmpp.error.client', function(error) {
error.type.should.equal('modify')
error.condition.should.equal('client-error')
- error.description.should.equal("Missing callback")
+ error.description.should.equal('Missing callback')
error.request.should.eql({})
xmpp.removeAllListeners('stanza')
done()
})
socket.emit('xmpp.roster.remove', {})
- })
+ })
- it('Errors when non-function callback provided', function(done) {
+ it('Errors when non-function callback provided', function(done) {
xmpp.once('stanza', function() {
done('Unexpected outgoing stanza')
})
socket.once('xmpp.error.client', function(error) {
error.type.should.equal('modify')
error.condition.should.equal('client-error')
- error.description.should.equal("Missing callback")
+ error.description.should.equal('Missing callback')
error.request.should.eql({})
xmpp.removeAllListeners('stanza')
done()
})
socket.emit('xmpp.roster.remove', {}, true)
- })
+ })
- it('Sends expected remove stanza', function(done) {
+ it('Sends expected remove stanza', function(done) {
var jid = 'alice@wonderland.lit'
xmpp.once('stanza', function(stanza) {
- stanza.is('iq').should.be.true
- stanza.attrs.type.should.equal('set')
- should.exist(stanza.attrs.id)
- var item = stanza.getChild('query', roster.NS).getChild('item')
- item.should.exist
- item.attrs.jid.should.equal(jid)
- item.attrs.subscription.should.equal('remove')
- manager.makeCallback(ltx.parse('<iq type="result" />'))
- })
+ stanza.is('iq').should.be.true
+ stanza.attrs.type.should.equal('set')
+ should.exist(stanza.attrs.id)
+ var item = stanza.getChild('query', roster.NS).getChild('item')
+ item.should.exist
+ item.attrs.jid.should.equal(jid)
+ item.attrs.subscription.should.equal('remove')
+ manager.makeCallback(ltx.parse('<iq type="result" />'))
+ })
var callback = function(error, success) {
should.not.exist(error)
success.should.be.true
done()
}
socket.emit('xmpp.roster.remove', { jid: jid }, callback)
- })
+ })
it('Can handle error response', function(done) {
var jid = 'alice@wonderland.lit'
xmpp.once('stanza', function(stanza) {
- stanza.is('iq').should.be.true
- stanza.attrs.type.should.equal('set')
- should.exist(stanza.attrs.id)
- var query = stanza.getChild('query', roster.NS)
- query.getChild('item').attrs.jid.should.equal(jid)
- manager.makeCallback(helper.getStanza('iq-error'))
- })
+ stanza.is('iq').should.be.true
+ stanza.attrs.type.should.equal('set')
+ should.exist(stanza.attrs.id)
+ var query = stanza.getChild('query', roster.NS)
+ query.getChild('item').attrs.jid.should.equal(jid)
+ manager.makeCallback(helper.getStanza('iq-error'))
+ })
var callback = function(error, success) {
should.not.exist(success)
error.should.eql({
View
3 test/lib/utils/xep-0004.js
@@ -1,8 +1,11 @@
+'use strict';
+
var dataForm = require('../../../index').utils['xep-0004']
, should = require('should')
, helper = require('../../helper')
, ltx = require('ltx')
+/* jshint -W030 */
describe('XEP-0004', function() {
it('Should export the data form namespace', function() {
View
39 test/lib/utils/xep-0059.js
@@ -1,6 +1,9 @@
+'use strict';
+
var rsm = require('../../../index').utils['xep-0059']
, ltx = require('ltx')
+/* jshint -W030 */
describe('XEP-0059', function() {
it('Should export the RSM namespace', function() {
@@ -30,49 +33,49 @@ describe('XEP-0059', function() {
rsm.build(stanza, { max: max })
var rsmElement = stanza.root().getChild('set', rsm.NS)
rsmElement.should.exist
- rsmElement.getChildText('max').should.equal("" + max)
- })
+ rsmElement.getChildText('max').should.equal('' + max)
+ })
- it('Adds <after> element if provided', function() {
+ it('Adds <after> element if provided', function() {
var after = 'item-id-1234'
rsm.build(stanza, { after: after })
var rsmElement = stanza.root().getChild('set', rsm.NS)
rsmElement.should.exist
rsmElement.getChildText('after').should.equal(after)
- })
+ })
- it('Adds <before> element if provided', function() {
+ it('Adds <before> element if provided', function() {
var before = 'item-id-1234'
rsm.build(stanza, { before: before })
var rsmElement = stanza.root().getChild('set', rsm.NS)
rsmElement.should.exist
rsmElement.getChildText('before').should.equal(before)
- })
+ })
- it('Adds empty <before> element if provided', function() {
- var before = true
- rsm.build(stanza, { before: before })
- var rsmElement = stanza.root().getChild('set', rsm.NS)
- rsmElement.should.exist
- rsmElement.getChild('before').toString().should.equal('<before/>')
- })
+ it('Adds empty <before> element if provided', function() {
+ var before = true
+ rsm.build(stanza, { before: before })
+ var rsmElement = stanza.root().getChild('set', rsm.NS)
+ rsmElement.should.exist
+ rsmElement.getChild('before').toString().should.equal('<before/>')
+ })
- it('Adds <index> element if provided', function() {
+ it('Adds <index> element if provided', function() {
var index = '1234'
rsm.build(stanza, { index: index })
var rsmElement = stanza.root().getChild('set', rsm.NS)
rsmElement.should.exist
rsmElement.getChildText('index').should.equal(index)
- })
+ })
- it('Can request 0 results', function() {
+ it('Can request 0 results', function() {
var max = 0
rsm.build(stanza, { max: 0 })
var rsmElement = stanza.root().getChild('set', rsm.NS)
rsmElement.should.exist
- rsmElement.getChildText('max').should.equal("" + max)
- })
+ rsmElement.getChildText('max').should.equal('' + max)
+ })
})
View
95 test/lib/utils/xep-0066.js
@@ -1,6 +1,9 @@
+'use strict';
+
var oob = require('../../../index').utils['xep-0066']
, ltx = require('ltx')
+/* jshint -W030 */
describe('XEP-0066', function() {
it('Should export the jabber:iq:oob namespace', function() {
@@ -22,77 +25,77 @@ describe('XEP-0066', function() {
describe('OOB X element', function() {
- it('Returns empty object if no OOB X element', function() {
- var data = oob.parse(
- ltx.parse('<iq><x xmlns="jabber:x:not-oob"/></iq>')
- )
- data.should.eql({})
- })
-
- it('Should add URL and DESC properties', function() {
- var url = 'http://www.shakepeare.lit'
- , description = 'Plays and sonnets'
- var stanza = ltx.parse(
+ it('Returns empty object if no OOB X element', function() {
+ var data = oob.parse(
+ ltx.parse('<iq><x xmlns="jabber:x:not-oob"/></iq>')
+ )
+ data.should.eql({})
+ })
+
+ it('Should add URL and DESC properties', function() {
+ var url = 'http://www.shakepeare.lit'
+ , description = 'Plays and sonnets'
+ var stanza = ltx.parse(
'<iq>' +
'<x xmlns="jabber:x:oob">' +
'<url>' + url + '</url>' +
'<desc>' + description + '</desc>' +
'</x>' +
'</iq>'
- )
- var data = oob.parse(stanza)
- data.url.should.equal(url)
- data.description.should.equal(description)
- })
-
- it('Shouldn\'t error if fields missing', function() {
- var stanza = ltx.parse(
+ )
+ var data = oob.parse(stanza)
+ data.url.should.equal(url)
+ data.description.should.equal(description)
+ })
+
+ it('Shouldn\'t error if fields missing', function() {
+ var stanza = ltx.parse(
'<iq>' +
'<x xmlns="jabber:x:oob"/>' +
'</iq>'
- )
- oob.parse(stanza).should.eql({})
- })
+ )
+ oob.parse(stanza).should.eql({})
+ })
})
describe('OOB IQ element', function() {
- it('Should add URL and DESC properties', function() {
- var url = 'http://www.shakepeare.lit'
- , description = 'Plays and sonnets'
- var stanza = ltx.parse(
- '<iq>' +
+ it('Should add URL and DESC properties', function() {
+ var url = 'http://www.shakepeare.lit'
+ , description = 'Plays and sonnets'
+ var stanza = ltx.parse(
+ '<iq>' +
'<query xmlns="jabber:iq:oob">' +
'<url>' + url + '</url>' +
'<desc>' + description + '</desc>' +
'</query>' +
- '</iq>'
- )
- var data = oob.parse(stanza)
- data.url.should.equal(url)
- data.description.should.equal(description)
- })
-
- it('Shouldn\'t error if fields missing', function() {
- var stanza = ltx.parse(
+ '</iq>'
+ )
+ var data = oob.parse(stanza)
+ data.url.should.equal(url)
+ data.description.should.equal(description)
+ })
+
+ it('Shouldn\'t error if fields missing', function() {
+ var stanza = ltx.parse(
'<iq>' +
'<query xmlns="jabber:iq:oob"/>' +
'</iq>'
- )
- oob.parse(stanza).should.eql({})
- })
+ )
+ oob.parse(stanza).should.eql({})
+ })
- it('Should add stream ID if present', function() {
- var stream = '0123456'
+ it('Should add stream ID if present', function() {
+ var stream = '0123456'
- var stanza = ltx.parse(
+ var stanza = ltx.parse(
'<iq>' +
'<query xmlns="jabber:iq:oob" sid="' + stream + '"/>' +
- '</iq>'
- )
- oob.parse(stanza).stream.should.equal(stream)
- })
+ '</iq>'
+ )
+ oob.parse(stanza).stream.should.equal(stream)
+ })
})
View
14 test/lib/utils/xep-0071.js
@@ -1,7 +1,10 @@
+'use strict';
+
var xep0071 = require('../../../index').utils['xep-0071']
, should = require('should')
, helper = require('../../helper')
+/* jshint -W030 */
describe('XEP-0071', function() {
var caller, xmpp
@@ -35,11 +38,12 @@ describe('XEP-0071', function() {
})
it('Returns empty stanza if no content key', function() {
- var result = xep0071.builder({}, { to: 'romeo@example.com' }, caller)
- result.is('message').should.be.true
- result.attrs.to.should.equal('romeo@example.com')
- result.attrs.type.should.equal('chat')
- })
+ var result = xep0071.builder({}, { to: 'romeo@example.com' }, caller)
+ result.is('message').should.be.true
+ result.attrs.to.should.equal('romeo@example.com')
+ result.attrs.type.should.equal('chat')
+ }
+ )
it('Can build a plain chat message', function() {
var request = { content: 'Hello world!', to: 'romeo@example.com' }
View
3 test/lib/utils/xep-0085.js
@@ -1,6 +1,9 @@
+'use strict';
+
var state = require('../../../index').utils['xep-0085']
, ltx = require('ltx')
+/* jshint -W030 */
describe('XEP-0085', function() {
it('Should export the chatstate namespace', function() {
View
3 test/lib/utils/xep-0203.js
@@ -1,6 +1,9 @@
+'use strict';
+
var delay = require('../../../index').utils['xep-0203']
, ltx = require('ltx')
+/* jshint -W030 */
describe('XEP-0203', function() {
it('Should export the delay namespace', function() {

0 comments on commit e17904f

Please sign in to comment.
Something went wrong with that request. Please try again.