- 18:50 fires:
- explodingcoder: hi :)
+ 18:50 luke:
+ leia: hi :)
19:40 me:
@@ -238,8 +243,8 @@
- jabberthehut
- - explodingcoder
- - jcbrand
+ - leia
+ - luke
@@ -249,7 +254,7 @@
-
problematic
+
Restricted Chatroom
diff --git a/non_amd.html b/non_amd.html
index 24f096c11..43b8276d0 100644
--- a/non_amd.html
+++ b/non_amd.html
@@ -16,7 +16,6 @@
-
diff --git a/spec/ChatRoomSpec.js b/spec/ChatRoomSpec.js
index 4fc6e3d4d..060c3c98b 100644
--- a/spec/ChatRoomSpec.js
+++ b/spec/ChatRoomSpec.js
@@ -135,7 +135,6 @@
.c('not-authorized').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
var view = this.chatboxesview.views['problematic@muc.localhost'];
- spyOn(converse.connection.muc, 'removeRoom');
spyOn(view, 'renderPasswordForm').andCallThrough();
runs(function () {
view.onChatRoomPresence(presence, {'nick': 'dummy'});
@@ -159,7 +158,6 @@
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'auth'})
.c('registration-required').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
var view = this.chatboxesview.views['problematic@muc.localhost'];
- spyOn(converse.connection.muc, 'removeRoom');
spyOn(view, 'showErrorMessage').andCallThrough();
view.onChatRoomPresence(presence, {'nick': 'dummy'});
expect(view.$el.find('.chat-body p').text()).toBe('You are not on the member list of this room');
@@ -175,7 +173,6 @@
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'auth'})
.c('forbidden').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
var view = this.chatboxesview.views['problematic@muc.localhost'];
- spyOn(converse.connection.muc, 'removeRoom');
spyOn(view, 'showErrorMessage').andCallThrough();
view.onChatRoomPresence(presence, {'nick': 'dummy'});
expect(view.$el.find('.chat-body p').text()).toBe('You have been banned from this room');
@@ -191,7 +188,6 @@
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'modify'})
.c('jid-malformed').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
var view = this.chatboxesview.views['problematic@muc.localhost'];
- spyOn(converse.connection.muc, 'removeRoom');
spyOn(view, 'showErrorMessage').andCallThrough();
view.onChatRoomPresence(presence, {'nick': 'dummy'});
expect(view.$el.find('.chat-body p').text()).toBe('No nickname was specified');
@@ -207,7 +203,6 @@
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'cancel'})
.c('not-allowed').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
var view = this.chatboxesview.views['problematic@muc.localhost'];
- spyOn(converse.connection.muc, 'removeRoom');
spyOn(view, 'showErrorMessage').andCallThrough();
view.onChatRoomPresence(presence, {'nick': 'dummy'});
expect(view.$el.find('.chat-body p').text()).toBe('You are not allowed to create new rooms');
@@ -223,7 +218,6 @@
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'cancel'})
.c('not-acceptable').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
var view = this.chatboxesview.views['problematic@muc.localhost'];
- spyOn(converse.connection.muc, 'removeRoom');
spyOn(view, 'showErrorMessage').andCallThrough();
view.onChatRoomPresence(presence, {'nick': 'dummy'});
expect(view.$el.find('.chat-body p').text()).toBe("Your nickname doesn't conform to this room's policies");
@@ -239,7 +233,6 @@
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'cancel'})
.c('conflict').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
var view = this.chatboxesview.views['problematic@muc.localhost'];
- spyOn(converse.connection.muc, 'removeRoom');
spyOn(view, 'showErrorMessage').andCallThrough();
view.onChatRoomPresence(presence, {'nick': 'dummy'});
expect(view.$el.find('.chat-body p').text()).toBe("Your nickname is already taken");
@@ -255,7 +248,6 @@
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'cancel'})
.c('item-not-found').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
var view = this.chatboxesview.views['problematic@muc.localhost'];
- spyOn(converse.connection.muc, 'removeRoom');
spyOn(view, 'showErrorMessage').andCallThrough();
view.onChatRoomPresence(presence, {'nick': 'dummy'});
expect(view.$el.find('.chat-body p').text()).toBe("This room does not (yet) exist");
@@ -271,7 +263,6 @@
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'cancel'})
.c('service-unavailable').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
var view = this.chatboxesview.views['problematic@muc.localhost'];
- spyOn(converse.connection.muc, 'removeRoom');
spyOn(view, 'showErrorMessage').andCallThrough();
view.onChatRoomPresence(presence, {'nick': 'dummy'});
expect(view.$el.find('.chat-body p').text()).toBe("This room has reached it's maximum number of occupants");
diff --git a/spec/MainSpec.js b/spec/MainSpec.js
index 818fddb6a..52d0ae25f 100644
--- a/spec/MainSpec.js
+++ b/spec/MainSpec.js
@@ -12,7 +12,7 @@
'Louw Spekman', 'Mohamad Stet', 'Dominik Beyer'
];
var pend_names = [
- 'Suleyman van Beusichem', 'Nicole Diederich', 'Nanja van Yperen'
+ 'Suleyman van Beusichem', 'Nanja van Yperen', 'Nicole Diederich'
];
var cur_names = [
'Max Frankfurter', 'Candice van der Knijff', 'Irini Vlastuin', 'Rinse Sommer', 'Annegreet Gomez',
@@ -123,6 +123,48 @@
expect(this.rosterview.$el.find('dt#pending-xmpp-contacts').css('display')).toEqual('none');
}, converse));
+ it("can be added to the roster", $.proxy(function () {
+ spyOn(this.rosterview, 'render').andCallThrough();
+ spyOn(this.xmppstatus, 'sendPresence');
+ this.roster.create({
+ jid: pend_names[0].replace(' ','.').toLowerCase() + '@localhost',
+ subscription: 'none',
+ ask: 'subscribe',
+ fullname: pend_names[0],
+ is_last: true
+ });
+ expect(this.rosterview.$el.is(':visible')).toEqual(true);
+ expect(this.xmppstatus.sendPresence).toHaveBeenCalled();
+ expect(this.rosterview.render).toHaveBeenCalled();
+ }, converse));
+
+ it("can be removed by the user", $.proxy(function () {
+ var view = _.toArray(this.rosterview.rosteritemviews).pop();
+ spyOn(window, 'confirm').andReturn(true);
+ spyOn(this.connection.roster, 'remove').andCallThrough();
+ spyOn(this.connection.roster, 'unauthorize');
+ spyOn(this.rosterview.model, 'remove').andCallThrough();
+ //spyOn(view, 'removeContact').andCallThrough();
+
+ runs($.proxy(function () {
+ view.$el.find('.remove-xmpp-contact').click();
+ }, converse));
+ waits(500);
+ runs($.proxy(function () {
+ expect(window.confirm).toHaveBeenCalled();
+ //expect(view.removeContact).toHaveBeenCalled();
+ expect(this.connection.roster.remove).toHaveBeenCalled();
+ expect(this.connection.roster.unauthorize).toHaveBeenCalled();
+ expect(this.rosterview.model.remove).toHaveBeenCalled();
+ // The element must now be detached from the DOM.
+ expect(view.$el.closest('html').length).toBeFalsy();
+ }, converse));
+ }, converse));
+
+ it("will lose their own heading once the last one has been removed", $.proxy(function () {
+ expect(this.rosterview.$el.find('dt#pending-xmpp-contacts').is(':visible')).toBeFalsy();
+ }, converse));
+
it("can be added to the roster and they will be sorted alphabetically", $.proxy(function () {
var i, t, is_last;
spyOn(this.rosterview, 'render').andCallThrough();
@@ -136,13 +178,10 @@
fullname: pend_names[i],
is_last: is_last
});
- // For performance reasons, the roster should only be shown once
- // the last contact has been added.
if (is_last) {
- expect(this.rosterview.$el.is(':visible')).toEqual(true);
expect(this.xmppstatus.sendPresence).toHaveBeenCalled();
} else {
- expect(this.rosterview.$el.is(':visible')).toEqual(false);
+ expect(this.xmppstatus.sendPresence).not.toHaveBeenCalled();
}
expect(this.rosterview.render).toHaveBeenCalled();
// Check that they are sorted alphabetically
@@ -154,6 +193,7 @@
it("will have their own heading once they have been added", $.proxy(function () {
expect(this.rosterview.$el.find('dt#pending-xmpp-contacts').css('display')).toEqual('block');
}, converse));
+
}, converse));
describe("Existing Contacts", $.proxy(function () {
diff --git a/tests_main.js b/tests_main.js
index 4228db78d..211193a87 100644
--- a/tests_main.js
+++ b/tests_main.js
@@ -68,37 +68,35 @@ require([
prebind: false,
xhr_user_search: false,
auto_subscribe: false,
- animate: false
+ animate: false,
+ connection: mock_connection,
+ testing: true
+ }, function (converse) {
+ window.converse = converse;
+ require([
+ "jasmine-console-reporter",
+ "jasmine-junit-reporter",
+ "spec/MainSpec",
+ "spec/ChatRoomSpec"
+ ], function () {
+ // Jasmine stuff
+ var jasmineEnv = jasmine.getEnv();
+ if (/PhantomJS/.test(navigator.userAgent)) {
+ jasmineEnv.addReporter(new jasmine.TrivialReporter());
+ jasmineEnv.addReporter(new jasmine.JUnitXmlReporter('./test-reports/'));
+ jasmineEnv.addReporter(new jasmine.ConsoleReporter());
+ jasmineEnv.updateInterval = 0;
+ } else {
+ var htmlReporter = new jasmine.HtmlReporter();
+ jasmineEnv.addReporter(htmlReporter);
+ jasmineEnv.addReporter(new jasmine.ConsoleReporter());
+ jasmineEnv.specFilter = function(spec) {
+ return htmlReporter.specFilter(spec);
+ };
+ jasmineEnv.updateInterval = 200;
+ }
+ jasmineEnv.execute();
+ });
});
- converse.onConnected(
- mock_connection,
- function (converse) {
- window.converse = converse;
- require([
- "jasmine-console-reporter",
- "jasmine-junit-reporter",
- "spec/MainSpec",
- "spec/ChatRoomSpec"
- ], function () {
- // Jasmine stuff
- var jasmineEnv = jasmine.getEnv();
- if (/PhantomJS/.test(navigator.userAgent)) {
- jasmineEnv.addReporter(new jasmine.TrivialReporter());
- jasmineEnv.addReporter(new jasmine.JUnitXmlReporter('./test-reports/'));
- jasmineEnv.addReporter(new jasmine.ConsoleReporter());
- jasmineEnv.updateInterval = 0;
- } else {
- var htmlReporter = new jasmine.HtmlReporter();
- jasmineEnv.addReporter(htmlReporter);
- jasmineEnv.addReporter(new jasmine.ConsoleReporter());
- jasmineEnv.specFilter = function(spec) {
- return htmlReporter.specFilter(spec);
- };
- jasmineEnv.updateInterval = 200;
- }
- jasmineEnv.execute();
- });
- }
- );
}
);