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 @@ ...@@ -3585,6 +3585,12 @@
'initialize': function (settings, callback) { 'initialize': function (settings, callback) {
converse.initialize(settings, callback); converse.initialize(settings, callback);
}, },
'getRID': function () {
if (typeof converse.connection !== "undefined") {
return converse.connection.rid;
}
return null;
},
'once': function(evt, handler) { 'once': function(evt, handler) {
converse.once(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([ ...@@ -100,6 +100,7 @@ require([
"jasmine-html" "jasmine-html"
], function($, converse, mock, jasmine) { ], function($, converse, mock, jasmine) {
// Set up converse.js // Set up converse.js
window.converse_api = converse;
window.localStorage.clear(); window.localStorage.clear();
converse.initialize({ converse.initialize({
prebind: false, prebind: false,
...@@ -122,6 +123,7 @@ require([ ...@@ -122,6 +123,7 @@ require([
require([ require([
"jasmine-console-reporter", "jasmine-console-reporter",
"jasmine-junit-reporter", "jasmine-junit-reporter",
"spec/converse",
"spec/otr", "spec/otr",
"spec/eventemitter", "spec/eventemitter",
"spec/controlbox", "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