1
0
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.4 KiB

14 years ago
var sys = require('sys'),
colors = require('colors'),
xmpp = require('node-xmpp'),
BasicClient = require('../lib/xmpp-client').BasicClient,
JID = require('node-xmpp').JID,
conf = require('./conf').conf;
exports.testInit = function(test) {
test.expect(1);
var b = new BasicClient(conf.b, function() {
14 years ago
test.ok(true, 'connected');
14 years ago
test.done();
});
14 years ago
};
exports.testIq = function(test) {
test.expect(1);
new BasicClient(conf.b, function() {
this.iq(null, new xmpp.Element('query', {xmlns: 'jabber:iq:roster'}), function(iq) {
var roster = iq.getChild('query', 'jabber:iq:roster').getChildren('item');
14 years ago
//sys.debug(roster);
14 years ago
test.notEqual(null, roster, 'roster');
test.done();
});
});
14 years ago
};
exports.testPresence = function(test) {
14 years ago
/*
[FIXME] this test don't manage Resource, if you have an opened jabber client, it may hurt this test
*/
14 years ago
test.expect(1);
14 years ago
var prems = true;
14 years ago
var b = new BasicClient(conf.b, function() {
this.addListener('presence', function(presence) {
14 years ago
//sys.debug(presence.attrs.from.red);
if(presence.attrs.from.split('/')[0] == conf.a.jid && prems) {
14 years ago
test.ok(true, "B is present");
test.done();
14 years ago
prems = false;
14 years ago
}
});
var a = new BasicClient(conf.a, function() {
this.addListener('presence', function(presence) {
//sys.debug(presence.toString().yellow);
});
this.presence();
b.presence();
});
});
14 years ago
};