|
@@ -3,20 +3,42 @@
|
|
} (this, function ($, jasmine, mock, converse, test_utils) {
|
|
} (this, function ($, jasmine, mock, converse, test_utils) {
|
|
var Strophe = converse.env.Strophe;
|
|
var Strophe = converse.env.Strophe;
|
|
var $iq = converse.env.$iq;
|
|
var $iq = converse.env.$iq;
|
|
|
|
+ var _ = converse.env._;
|
|
|
|
|
|
describe("The Registration Panel", function () {
|
|
describe("The Registration Panel", function () {
|
|
|
|
|
|
- it("is not available unless allow_registration=true", mock.initConverse(function (_converse) {
|
|
|
|
|
|
+ it("is not available unless allow_registration=true",
|
|
|
|
+ mock.initConverseWithPromises(
|
|
|
|
+ null, ['connectionInitialized', 'chatBoxesInitialized'],
|
|
|
|
+ { auto_login: false,
|
|
|
|
+ allow_registration: false },
|
|
|
|
+ function (done, _converse) {
|
|
|
|
+
|
|
|
|
+ test_utils.waitUntil(function () {
|
|
|
|
+ return _converse.chatboxviews.get('controlbox');
|
|
|
|
+ }, 300)
|
|
|
|
+ .then(function () {
|
|
|
|
+
|
|
test_utils.openControlBox();
|
|
test_utils.openControlBox();
|
|
var cbview = _converse.chatboxviews.get('controlbox');
|
|
var cbview = _converse.chatboxviews.get('controlbox');
|
|
expect(cbview.$('#controlbox-tabs li').length).toBe(1);
|
|
expect(cbview.$('#controlbox-tabs li').length).toBe(1);
|
|
expect(cbview.$('#controlbox-tabs li').text().trim()).toBe("Sign in");
|
|
expect(cbview.$('#controlbox-tabs li').text().trim()).toBe("Sign in");
|
|
-
|
|
|
|
- }, { auto_login: false,
|
|
|
|
- allow_registration: false,
|
|
|
|
|
|
+ done();
|
|
|
|
+ });
|
|
}));
|
|
}));
|
|
|
|
|
|
- it("can be opened by clicking on the registration tab", mock.initConverse(function (_converse) {
|
|
|
|
|
|
+ it("can be opened by clicking on the registration tab",
|
|
|
|
+ mock.initConverseWithPromises(
|
|
|
|
+ null, ['connectionInitialized', 'chatBoxesInitialized'],
|
|
|
|
+ { auto_login: false,
|
|
|
|
+ allow_registration: true },
|
|
|
|
+ function (done, _converse) {
|
|
|
|
+
|
|
|
|
+ test_utils.waitUntil(function () {
|
|
|
|
+ return _.get(_converse.chatboxviews.get('controlbox'), 'registerpanel');
|
|
|
|
+ }, 300)
|
|
|
|
+ .then(function () {
|
|
|
|
+
|
|
var cbview = _converse.chatboxviews.get('controlbox');
|
|
var cbview = _converse.chatboxviews.get('controlbox');
|
|
test_utils.openControlBox();
|
|
test_utils.openControlBox();
|
|
var $tabs = cbview.$('#controlbox-tabs');
|
|
var $tabs = cbview.$('#controlbox-tabs');
|
|
@@ -32,12 +54,22 @@
|
|
expect($login.is(':visible')).toBe(false);
|
|
expect($login.is(':visible')).toBe(false);
|
|
expect($registration.is(':visible')).toBe(true);
|
|
expect($registration.is(':visible')).toBe(true);
|
|
expect(cbview.switchTab).toHaveBeenCalled();
|
|
expect(cbview.switchTab).toHaveBeenCalled();
|
|
-
|
|
|
|
- }, { auto_login: false,
|
|
|
|
- allow_registration: true,
|
|
|
|
|
|
+ done();
|
|
|
|
+ });
|
|
}));
|
|
}));
|
|
|
|
|
|
- it("allows the user to choose an XMPP provider's domain", mock.initConverse(function (_converse) {
|
|
|
|
|
|
+ it("allows the user to choose an XMPP provider's domain",
|
|
|
|
+ mock.initConverseWithPromises(
|
|
|
|
+ null, ['connectionInitialized', 'chatBoxesInitialized'],
|
|
|
|
+ { auto_login: false,
|
|
|
|
+ allow_registration: true },
|
|
|
|
+ function (done, _converse) {
|
|
|
|
+
|
|
|
|
+ test_utils.waitUntil(function () {
|
|
|
|
+ return _.get(_converse.chatboxviews.get('controlbox'), 'registerpanel');
|
|
|
|
+ }, 300)
|
|
|
|
+ .then(function () {
|
|
|
|
+
|
|
var cbview = _converse.chatboxviews.get('controlbox');
|
|
var cbview = _converse.chatboxviews.get('controlbox');
|
|
var registerview = cbview.registerpanel;
|
|
var registerview = cbview.registerpanel;
|
|
spyOn(registerview, 'onProviderChosen').and.callThrough();
|
|
spyOn(registerview, 'onProviderChosen').and.callThrough();
|
|
@@ -59,11 +91,22 @@
|
|
$form.find('input[type=submit]').click();
|
|
$form.find('input[type=submit]').click();
|
|
expect(registerview.onProviderChosen).toHaveBeenCalled();
|
|
expect(registerview.onProviderChosen).toHaveBeenCalled();
|
|
expect(_converse.connection.connect).toHaveBeenCalled();
|
|
expect(_converse.connection.connect).toHaveBeenCalled();
|
|
- }, { auto_login: false,
|
|
|
|
- allow_registration: true,
|
|
|
|
- }));
|
|
|
|
|
|
+ done();
|
|
|
|
+ });
|
|
|
|
+ }));
|
|
|
|
+
|
|
|
|
+ it("will render a registration form as received from the XMPP provider",
|
|
|
|
+ mock.initConverseWithPromises(
|
|
|
|
+ null, ['connectionInitialized', 'chatBoxesInitialized'],
|
|
|
|
+ { auto_login: false,
|
|
|
|
+ allow_registration: true },
|
|
|
|
+ function (done, _converse) {
|
|
|
|
+
|
|
|
|
+ test_utils.waitUntil(function () {
|
|
|
|
+ return _.get(_converse.chatboxviews.get('controlbox'), 'registerpanel');
|
|
|
|
+ }, 300)
|
|
|
|
+ .then(function () {
|
|
|
|
|
|
- it("will render a registration form as received from the XMPP provider", mock.initConverse(function (_converse) {
|
|
|
|
var cbview = _converse.chatboxviews.get('controlbox');
|
|
var cbview = _converse.chatboxviews.get('controlbox');
|
|
cbview.$('#controlbox-tabs').find('li').last().find('a').click(); // Click the Register tab
|
|
cbview.$('#controlbox-tabs').find('li').last().find('a').click(); // Click the Register tab
|
|
var registerview = _converse.chatboxviews.get('controlbox').registerpanel;
|
|
var registerview = _converse.chatboxviews.get('controlbox').registerpanel;
|
|
@@ -107,14 +150,25 @@
|
|
expect(registerview.$('input').length).toBe(5);
|
|
expect(registerview.$('input').length).toBe(5);
|
|
expect(registerview.$('input[type=submit]').length).toBe(1);
|
|
expect(registerview.$('input[type=submit]').length).toBe(1);
|
|
expect(registerview.$('input[type=button]').length).toBe(1);
|
|
expect(registerview.$('input[type=button]').length).toBe(1);
|
|
- }, { auto_login: false,
|
|
|
|
- allow_registration: true,
|
|
|
|
- }));
|
|
|
|
|
|
+ done();
|
|
|
|
+ });
|
|
|
|
+ }));
|
|
|
|
+
|
|
|
|
+ it("will set form_type to legacy and submit it as legacy",
|
|
|
|
+ mock.initConverseWithPromises(
|
|
|
|
+ null, ['connectionInitialized', 'chatBoxesInitialized'],
|
|
|
|
+ { auto_login: false,
|
|
|
|
+ allow_registration: true },
|
|
|
|
+ function (done, _converse) {
|
|
|
|
+
|
|
|
|
+ test_utils.waitUntil(function () {
|
|
|
|
+ return _.get(_converse.chatboxviews.get('controlbox'), 'registerpanel');
|
|
|
|
+ }, 300)
|
|
|
|
+ .then(function () {
|
|
|
|
|
|
- it("will set form_type to legacy and submit it as legacy", mock.initConverse(function (_converse) {
|
|
|
|
var cbview = _converse.chatboxviews.get('controlbox');
|
|
var cbview = _converse.chatboxviews.get('controlbox');
|
|
cbview.$('#controlbox-tabs').find('li').last().find('a').click(); // Click the Register tab
|
|
cbview.$('#controlbox-tabs').find('li').last().find('a').click(); // Click the Register tab
|
|
- var registerview = _converse.chatboxviews.get('controlbox').registerpanel;
|
|
|
|
|
|
+ var registerview = cbview.registerpanel;
|
|
spyOn(registerview, 'onProviderChosen').and.callThrough();
|
|
spyOn(registerview, 'onProviderChosen').and.callThrough();
|
|
spyOn(registerview, 'getRegistrationFields').and.callThrough();
|
|
spyOn(registerview, 'getRegistrationFields').and.callThrough();
|
|
spyOn(registerview, 'onRegistrationFields').and.callThrough();
|
|
spyOn(registerview, 'onRegistrationFields').and.callThrough();
|
|
@@ -156,11 +210,22 @@
|
|
var $stanza = $(_converse.connection.send.calls.argsFor(0)[0].tree());
|
|
var $stanza = $(_converse.connection.send.calls.argsFor(0)[0].tree());
|
|
expect($stanza.children('query').children().length).toBe(3);
|
|
expect($stanza.children('query').children().length).toBe(3);
|
|
expect($stanza.children('query').children()[0].tagName).toBe('username');
|
|
expect($stanza.children('query').children()[0].tagName).toBe('username');
|
|
- }, { auto_login: false,
|
|
|
|
- allow_registration: true,
|
|
|
|
- }));
|
|
|
|
|
|
+ done();
|
|
|
|
+ });
|
|
|
|
+ }));
|
|
|
|
+
|
|
|
|
+ it("will set form_type to xform and submit it as xform",
|
|
|
|
+ mock.initConverseWithPromises(
|
|
|
|
+ null, ['connectionInitialized', 'chatBoxesInitialized'],
|
|
|
|
+ { auto_login: false,
|
|
|
|
+ allow_registration: true },
|
|
|
|
+ function (done, _converse) {
|
|
|
|
+
|
|
|
|
+ test_utils.waitUntil(function () {
|
|
|
|
+ return _.get(_converse.chatboxviews.get('controlbox'), 'registerpanel');
|
|
|
|
+ }, 300)
|
|
|
|
+ .then(function () {
|
|
|
|
|
|
- it("will set form_type to xform and submit it as xform", mock.initConverse(function (_converse) {
|
|
|
|
var cbview = _converse.chatboxviews.get('controlbox');
|
|
var cbview = _converse.chatboxviews.get('controlbox');
|
|
cbview.$('#controlbox-tabs').find('li').last().find('a').click(); // Click the Register tab
|
|
cbview.$('#controlbox-tabs').find('li').last().find('a').click(); // Click the Register tab
|
|
var registerview = _converse.chatboxviews.get('controlbox').registerpanel;
|
|
var registerview = _converse.chatboxviews.get('controlbox').registerpanel;
|
|
@@ -208,8 +273,8 @@
|
|
expect($stanza.children('query').children().length).toBe(1);
|
|
expect($stanza.children('query').children().length).toBe(1);
|
|
expect($stanza.children('query').children().children().length).toBe(3);
|
|
expect($stanza.children('query').children().children().length).toBe(3);
|
|
expect($stanza.children('query').children().children()[0].tagName).toBe('field');
|
|
expect($stanza.children('query').children().children()[0].tagName).toBe('field');
|
|
- }, { auto_login: false,
|
|
|
|
- allow_registration: true,
|
|
|
|
- }));
|
|
|
|
|
|
+ done();
|
|
|
|
+ });
|
|
|
|
+ }));
|
|
});
|
|
});
|
|
}));
|
|
}));
|