1
0
Fork 0
master
Matthieu Lalonde 14 years ago committed by Mathieu Lecarme
parent 681fc3f890
commit c3fbac6019

@ -0,0 +1,26 @@
var sys = require('sys'),
colors = require('colors'),
xmpp = require('node-xmpp'),
Client = require('../lib/xmpp-client').Client,
conf = require('./conf').conf;
exports.testClient = function(test) {
test.expect(3);
var MESSAGE = "Beuha de test!";
var b = new Client(conf.b, function() {
this.addListener('message', function(stanza){
sys.debug('Message from ' + stanza.toString().red);
test.equals(MESSAGE, stanza.getChild('body').getText());
test.done();
});
sys.debug('b is connected'.red);
test.ok(true);
var a = new Client(conf.a, function(){
sys.debug('a is connected'.green);
sys.debug('a presences : ' + JSON.stringify(a.presences).green);
// test.equals('available', a.presences['' + b.jid]);
test.ok(true);
a.message(conf.b.jid, MESSAGE);
});
});
};

@ -2,22 +2,8 @@ var sys = require('sys'),
colors = require('colors'),
xmpp = require('node-xmpp'),
Client = require('../lib/xmpp-client').Client,
JID = require('node-xmpp').JID,
conf = require('./conf').conf;
exports.testJid = function(test) {
test.expect(4);
var j = new JID('mathieu@gtalk.com');
//sys.debug(JSON.stringify(j));
test.equals('mathieu', j.user);
test.equals('gtalk.com', j.domain);
test.equals(null, j.resource);
j = new JID('mathieu@jabber.org/machin');
//sys.debug(JSON.stringify(j));
test.equals('machin', j.resource);
test.done();
};
exports.testClientInit = function(test) {
var c = new Client({jid: 'mathieu@gtalk.com', password:'toto'});
test.equals('gtalk.com', c.host);
@ -90,35 +76,25 @@ exports.testPubSub = function(test) {
sys.error(stanza.toString().red);
test.done();
});
var p = b.pubsub();
/*p.discoNode(POEMS, function(r) {
sys.debug(r);
});*/
p.node(POEMS, function() {
this.pubsub().node(POEMS, function() {
sys.debug('got my node'.yellow);
p.suscribe(POEMS,
sys.debug('node : ' + this.toString().red);
this.suscribe(
function(item) {
sys.debug('MESSAGE PUBSUB : ' + item.toString().yellow);
test.done();
},
function(subsription, id) {
p.publish(POEMS, new xmpp.Element('entry', {xmlns: 'http://www.w3.org/2005/Atom'})
this.publish(new xmpp.Element('entry', {xmlns: 'http://www.w3.org/2005/Atom'})
.c('title').t('blab blah')
.tree());
}
);
//test.done();
});
/*
b.suscribe(null, POEMS, function(item) {
sys.debug(item.attrs.id.yellow);
});
*/
//b.publish(null, POEMS, );
});
};
if(module.id == '.') {
var testrunner = require('nodeunit').testrunner;
/*if(module.id == '.') {
var testrunner = require('nodeunit').reporters.default;
testrunner.run([__filename]);
}
}*/

Loading…
Cancel
Save