Skip to content
Browse files

Test cases for missing attributes.

  • Loading branch information...
1 parent e92561f commit 4a371ef0f6215e7322e53078d0b4efd936622400 @jaredhanson committed Jun 25, 2012
Showing with 48 additions and 0 deletions.
  1. +48 −0 test/delayParser-test.js
View
48 test/delayParser-test.js
@@ -107,6 +107,54 @@ vows.describe('delayParser').addBatch({
},
},
+ 'when handling a message stanza with delay lacking from': {
+ topic: function(delayParser) {
+ var self = this;
+ var msg = new junction.XMLElement('message', { from: 'romeo@example.net/orchard' });
+ msg.c('delay', { xmlns: 'urn:xmpp:delay',
+ stamp: '2002-09-10T23:08:25Z' });
+
+ function next(err) {
+ self.callback(err, msg);
+ }
+ process.nextTick(function () {
+ delayParser(msg, next)
+ });
+ },
+
+ 'should not set delayedBy property' : function(err, stanza) {
+ assert.isUndefined(stanza.delayedBy);
+ },
+ 'should set originallySentAt property' : function(err, stanza) {
+ assert.instanceOf(stanza.originallySentAt, Date);
+ assert.equal(stanza.originallySentAt.toUTCString(), 'Tue, 10 Sep 2002 23:08:25 GMT');
+ },
+ },
+
+ 'when handling a malformed message stanza with delay lacking stamp': {
+ topic: function(delayParser) {
+ var self = this;
+ var msg = new junction.XMLElement('message', { from: 'romeo@example.net/orchard' });
+ msg.c('delay', { xmlns: 'urn:xmpp:delay',
+ from: 'capulet.com' });
+
+ function next(err) {
+ self.callback(err, msg);
+ }
+ process.nextTick(function () {
+ delayParser(msg, next)
+ });
+ },
+
+ 'should set delayedBy property' : function(err, stanza) {
+ assert.instanceOf(stanza.delayedBy, junction.JID);
+ assert.equal(stanza.delayedBy, 'capulet.com');
+ },
+ 'should not set originallySentAt property' : function(err, stanza) {
+ assert.isUndefined(stanza.originallySentAt)
+ },
+ },
+
'when handling a non-message, non-presence stanza': {
topic: function(delayParser) {
var self = this;

0 comments on commit 4a371ef

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