Commit 30f3114c authored by JC Brand's avatar JC Brand

Add method to get the latest RID. Updates #93

parent 1a4044dd
......@@ -3585,6 +3585,12 @@
'initialize': function (settings, callback) {
converse.initialize(settings, callback);
},
'getRID': function () {
if (typeof converse.connection !== "undefined") {
return converse.connection.rid;
}
return null;
},
'once': function(evt, handler) {
converse.once(evt, handler);
},
......
(function (root, factory) {
define([
"mock",
"utils"
], function (mock, utils) {
return factory(mock, utils);
}
);
} (this, function (mock, utils) {
return describe("Converse", $.proxy(function(mock, utils) {
beforeEach($.proxy(function () {
window.localStorage.clear();
window.sessionStorage.clear();
}, converse));
it("has an API method for retrieving the next RID", $.proxy(function () {
var old_connection = converse.connection;
converse.connection.rid = '1234';
expect(converse_api.getRID()).toBe('1234');
converse.connection = undefined;
expect(converse_api.getRID()).toBe(null);
// Restore the connection
converse.connection = old_connection;
}, converse));
}, converse, mock, utils));
}));
......@@ -100,6 +100,7 @@ require([
"jasmine-html"
], function($, converse, mock, jasmine) {
// Set up converse.js
window.converse_api = converse;
window.localStorage.clear();
converse.initialize({
prebind: false,
......@@ -122,6 +123,7 @@ require([
require([
"jasmine-console-reporter",
"jasmine-junit-reporter",
"spec/converse",
"spec/otr",
"spec/eventemitter",
"spec/controlbox",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment