2014-02-12 11:19:12 +01:00
|
|
|
(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;
|
2014-06-14 22:03:04 +02:00
|
|
|
converse.connection._proto.rid = '1234';
|
2014-02-12 11:37:39 +01:00
|
|
|
converse.expose_rid_and_sid = false;
|
|
|
|
expect(converse_api.getRID()).toBe(null);
|
|
|
|
|
|
|
|
converse.expose_rid_and_sid = true;
|
2014-02-12 11:19:12 +01:00
|
|
|
expect(converse_api.getRID()).toBe('1234');
|
2014-02-12 11:37:39 +01:00
|
|
|
|
2014-02-12 11:19:12 +01:00
|
|
|
converse.connection = undefined;
|
|
|
|
expect(converse_api.getRID()).toBe(null);
|
|
|
|
// Restore the connection
|
|
|
|
converse.connection = old_connection;
|
|
|
|
}, converse));
|
2014-02-12 11:37:39 +01:00
|
|
|
|
|
|
|
it("has an API method for retrieving the SID", $.proxy(function () {
|
|
|
|
var old_connection = converse.connection;
|
2014-06-14 22:03:04 +02:00
|
|
|
converse.connection._proto.sid = '1234';
|
2014-02-12 11:37:39 +01:00
|
|
|
converse.expose_rid_and_sid = false;
|
|
|
|
expect(converse_api.getSID()).toBe(null);
|
|
|
|
|
|
|
|
converse.expose_rid_and_sid = true;
|
|
|
|
expect(converse_api.getSID()).toBe('1234');
|
|
|
|
|
|
|
|
converse.connection = undefined;
|
|
|
|
expect(converse_api.getSID()).toBe(null);
|
|
|
|
// Restore the connection
|
|
|
|
converse.connection = old_connection;
|
|
|
|
}, converse));
|
2014-02-12 11:19:12 +01:00
|
|
|
}, converse, mock, utils));
|
|
|
|
}));
|