[Pkg-javascript-commits] [ltx] 51/469: JID.equals() + test

Jonas Smedegaard dr at jones.dk
Wed Aug 31 13:00:59 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository ltx.

commit 5f59a43181a7b6316ae6892c754b98d4154aff2c
Author: Astro <astro at spaceboyz.net>
Date:   Sat Aug 14 00:05:52 2010 +0200

    JID.equals() + test
---
 lib/xmpp/jid.js  |  6 ++++++
 test/test_jid.js | 16 ++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/lib/xmpp/jid.js b/lib/xmpp/jid.js
index 0f0ff67..296d427 100644
--- a/lib/xmpp/jid.js
+++ b/lib/xmpp/jid.js
@@ -37,4 +37,10 @@ JID.prototype.bare = function() {
 	return this;
 };
 
+JID.prototype.equals = function(other) {
+    return this.user == other.user &&
+	this.domain == other.domain &&
+	this.resource == other.resource;
+};
+
 exports.JID = JID;
diff --git a/test/test_jid.js b/test/test_jid.js
index 49801c4..3e26470 100644
--- a/test/test_jid.js
+++ b/test/test_jid.js
@@ -57,6 +57,22 @@ vows.describe('JID').addBatch({
 	    var j = new xmpp.JID('u', 'd', 'r');
 	    assert.equal(j.toString(), 'u at d/r');
 	}
+    },
+
+    'equality': {
+	'parsed JIDs should be equal':
+	function() {
+	    var j1 = new xmpp.JID('foo at bar/baz');
+	    var j2 = new xmpp.JID('foo at bar/baz');
+	    assert.equal(j1.equals(j2), true);
+	},
+	'parsed JIDs should be not equal':
+	function() {
+	    var j1 = new xmpp.JID('foo at bar/baz');
+	    var j2 = new xmpp.JID('quux at bar/baz');
+	    assert.equal(j1.equals(j2), false);
+	}
+
     }
 
 }).run();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/ltx.git



More information about the Pkg-javascript-commits mailing list