Commit 0c43e4b8 authored by JC Brand's avatar JC Brand

Upgrade to Jasmine 2.5.3

parent bf9ba245
...@@ -255,7 +255,7 @@ ...@@ -255,7 +255,7 @@
"error", "error",
"never" "never"
], ],
"valid-jsdoc": "error", "valid-jsdoc": "off",
"vars-on-top": "off", "vars-on-top": "off",
"wrap-iife": [ "wrap-iife": [
"error", "error",
......
...@@ -3,7 +3,6 @@ BUILDDIR = ./docs ...@@ -3,7 +3,6 @@ BUILDDIR = ./docs
BUNDLE ?= ./.bundle/bin/bundle BUNDLE ?= ./.bundle/bin/bundle
GRUNT ?= ./node_modules/.bin/grunt GRUNT ?= ./node_modules/.bin/grunt
HTTPSERVE ?= ./node_modules/.bin/http-server HTTPSERVE ?= ./node_modules/.bin/http-server
JSHINT ?= ./node_modules/.bin/jshint
ESLINT ?= ./node_modules/.bin/eslint ESLINT ?= ./node_modules/.bin/eslint
PAPER = PAPER =
PHANTOMJS ?= ./node_modules/.bin/phantomjs PHANTOMJS ?= ./node_modules/.bin/phantomjs
...@@ -16,13 +15,6 @@ SPHINXOPTS = ...@@ -16,13 +15,6 @@ SPHINXOPTS =
# Internal variables. # Internal variables.
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) ./docs/source ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) ./docs/source
SOURCES = $(wildcard *.js) $(wildcard spec/*.js) $(wildcard src/*.js)
JSHINTEXCEPTIONS = $(GENERATED) \
src/build-mobile.js \
src/build-no-jquery.js \
src/build-no-dependencies.js \
src/build.js \
CHECKSOURCES = $(filter-out $(JSHINTEXCEPTIONS),$(SOURCES))
.PHONY: all .PHONY: all
all: dev dist all: dev dist
...@@ -184,18 +176,15 @@ build:: dev css ...@@ -184,18 +176,15 @@ build:: dev css
######################################################################## ########################################################################
## Tests ## Tests
.PHONY: jshint
jshint: stamp-npm
$(JSHINT) --config jshintrc $(CHECKSOURCES)
.PHONY: eslint .PHONY: eslint
eslint: stamp-npm eslint: stamp-npm
$(ESLINT) src/ $(ESLINT) src/
$(ESLINT) spec/ $(ESLINT) spec/
.PHONY: check .PHONY: check
check: jshint eslint check: eslint
$(PHANTOMJS) node_modules/phantom-jasmine/lib/run_jasmine_test.coffee tests.html $(PHANTOMJS) tests/run-jasmine2.js tests.html
######################################################################## ########################################################################
## Documentation ## Documentation
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
## 3.0.2 (Unreleased) ## 3.0.2 (Unreleased)
- No changes yet. - Update Jasmine from 1.3.1 to 2.5.3 and Phantomjs from 1.9.7-1 to 2.1.14 [jcbrand]
## 3.0.1 (2017-04-04) ## 3.0.1 (2017-04-04)
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
"bootstrap": "^3.3.7", "bootstrap": "^3.3.7",
"bourbon": "^4.3.2", "bourbon": "^4.3.2",
"clean-css": "^3.4.19", "clean-css": "^3.4.19",
"es6-promise": "^4.1.0",
"eslint": "^3.16.1", "eslint": "^3.16.1",
"eslint-plugin-lodash": "^2.3.3", "eslint-plugin-lodash": "^2.3.3",
"font-awesome": "^4.7.0", "font-awesome": "^4.7.0",
...@@ -49,7 +50,7 @@ ...@@ -49,7 +50,7 @@
"grunt-json": "^0.2.0", "grunt-json": "^0.2.0",
"http-server": "^0.9.0", "http-server": "^0.9.0",
"install": "^0.8.5", "install": "^0.8.5",
"jasmine": "https://github.com/jcbrand/jasmine.git#439a7f805eeaec0cabe18a8ecf7e47da1a0afa33", "jasmine": "2.5.3",
"jed": "0.5.4", "jed": "0.5.4",
"jquery": "2.2.3", "jquery": "2.2.3",
"jquery-easing": "0.0.1", "jquery-easing": "0.0.1",
...@@ -60,8 +61,7 @@ ...@@ -60,8 +61,7 @@
"moment": "~2.13.0", "moment": "~2.13.0",
"npm": "^4.1.1", "npm": "^4.1.1",
"otr": "0.2.16", "otr": "0.2.16",
"phantom-jasmine": "0.1.8", "phantomjs-prebuilt": "~2.1.14",
"phantomjs": "~1.9.7-1",
"pluggable.js": "1.0.0", "pluggable.js": "1.0.0",
"po2json": "^0.4.4", "po2json": "^0.4.4",
"requirejs": "2.3.3", "requirejs": "2.3.3",
...@@ -73,7 +73,8 @@ ...@@ -73,7 +73,8 @@
"strophejs-plugin-register": "0.0.1", "strophejs-plugin-register": "0.0.1",
"strophejs-plugin-rsm": "0.0.1", "strophejs-plugin-rsm": "0.0.1",
"strophejs-plugin-vcard": "0.0.1", "strophejs-plugin-vcard": "0.0.1",
"text": "requirejs/text#2.0.15" "text": "requirejs/text#2.0.15",
"wait-until-promise": "^1.0.0"
}, },
"dependencies": {} "dependencies": {}
} }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
define([ define([
"converse-core", "converse-core",
"mock", "mock",
"test_utils"], factory); "test-utils"], factory);
} (this, function (converse, mock, test_utils) { } (this, function (converse, mock, test_utils) {
var b64_sha1 = converse.env.b64_sha1; var b64_sha1 = converse.env.b64_sha1;
var _ = converse.env._; var _ = converse.env._;
...@@ -52,9 +52,9 @@ ...@@ -52,9 +52,9 @@
describe("A chat state indication", function () { describe("A chat state indication", function () {
it("are sent out when the client becomes or stops being idle", mock.initConverse(function (_converse) { it("are sent out when the client becomes or stops being idle", mock.initConverse(function (_converse) {
spyOn(_converse, 'sendCSI').andCallThrough(); spyOn(_converse, 'sendCSI').and.callThrough();
var sent_stanza; var sent_stanza;
spyOn(_converse.connection, 'send').andCallFake(function (stanza) { spyOn(_converse.connection, 'send').and.callFake(function (stanza) {
sent_stanza = stanza; sent_stanza = stanza;
}); });
var i = 0; var i = 0;
...@@ -298,26 +298,23 @@ ...@@ -298,26 +298,23 @@
test_utils.createContacts(_converse, 'current'); test_utils.createContacts(_converse, 'current');
var jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; var jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
var chatboxview; var chatboxview;
waits('300'); // ChatBox.show() is debounced for 250ms // Test on chat that doesn't exist.
runs(function () { expect(_converse.api.chats.get('non-existing@jabber.org')).toBeFalsy();
// Test on chat that doesn't exist. var box = _converse.api.chats.open(jid);
expect(_converse.api.chats.get('non-existing@jabber.org')).toBeFalsy(); expect(box instanceof Object).toBeTruthy();
var box = _converse.api.chats.open(jid); expect(box.model.get('box_id')).toBe(b64_sha1(jid));
expect(box instanceof Object).toBeTruthy(); expect(
expect(box.model.get('box_id')).toBe(b64_sha1(jid)); _.keys(box),
expect( ['close', 'endOTR', 'focus', 'get', 'initiateOTR', 'is_chatroom', 'maximize', 'minimize', 'open', 'set']
_.keys(box), );
['close', 'endOTR', 'focus', 'get', 'initiateOTR', 'is_chatroom', 'maximize', 'minimize', 'open', 'set'] chatboxview = _converse.chatboxviews.get(jid);
); expect(chatboxview.$el.is(':visible')).toBeTruthy();
chatboxview = _converse.chatboxviews.get(jid); // Test for multiple JIDs
expect(chatboxview.$el.is(':visible')).toBeTruthy(); var jid2 = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@localhost';
// Test for multiple JIDs var list = _converse.api.chats.open([jid, jid2]);
var jid2 = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@localhost'; expect(_.isArray(list)).toBeTruthy();
var list = _converse.api.chats.open([jid, jid2]); expect(list[0].model.get('box_id')).toBe(b64_sha1(jid));
expect(_.isArray(list)).toBeTruthy(); expect(list[1].model.get('box_id')).toBe(b64_sha1(jid2));
expect(list[0].model.get('box_id')).toBe(b64_sha1(jid));
expect(list[1].model.get('box_id')).toBe(b64_sha1(jid2));
});
})); }));
}); });
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"jquery", "jquery",
"converse-core", "converse-core",
"mock", "mock",
"test_utils"], factory); "test-utils"], factory);
} (this, function ($, converse, mock, test_utils) { } (this, function ($, converse, mock, test_utils) {
"use strict"; "use strict";
var Strophe = converse.env.Strophe; var Strophe = converse.env.Strophe;
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
describe("Service Discovery", function () { describe("Service Discovery", function () {
describe("Whenever converse.js discovers a new server feature", function () { describe("Whenever converse.js discovers a new server feature", function () {
it("emits the serviceDiscovered event", mock.initConverse(function (_converse) { it("emits the serviceDiscovered event", mock.initConverse(function (_converse) {
spyOn(_converse, 'emit'); sinon.spy(_converse, 'emit');
_converse.features.create({'var': Strophe.NS.MAM}); _converse.features.create({'var': Strophe.NS.MAM});
expect(_converse.emit).toHaveBeenCalled(); expect(_converse.emit.called).toBe(true);
expect(_converse.emit.argsForCall[0][1].get('var')).toBe(Strophe.NS.MAM); expect(_converse.emit.args[0][1].get('var')).toBe(Strophe.NS.MAM);
})); }));
}); });
}); });
......
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "test_utils"], factory); define(["mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) { } (this, function (mock, converse, test_utils) {
return describe("The _converse Event Emitter", function() { return describe("The _converse Event Emitter", function() {
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
_converse.emit('connected'); _converse.emit('connected');
expect(this.callback).toHaveBeenCalled(); expect(this.callback).toHaveBeenCalled();
_converse.emit('connected'); _converse.emit('connected');
expect(this.callback.callCount, 2); expect(this.callback.calls.count(), 2);
_converse.emit('connected'); _converse.emit('connected');
expect(this.callback.callCount, 3); expect(this.callback.calls.count(), 3);
})); }));
it("allows you to listen once for an emitted event", mock.initConverse(function (_converse) { it("allows you to listen once for an emitted event", mock.initConverse(function (_converse) {
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
_converse.emit('connected'); _converse.emit('connected');
expect(this.callback).toHaveBeenCalled(); expect(this.callback).toHaveBeenCalled();
_converse.emit('connected'); _converse.emit('connected');
expect(this.callback.callCount, 1); expect(this.callback.calls.count(), 1);
_converse.emit('connected'); _converse.emit('connected');
expect(this.callback.callCount, 1); expect(this.callback.calls.count(), 1);
})); }));
it("allows you to stop listening or subscribing to an event", mock.initConverse(function (_converse) { it("allows you to stop listening or subscribing to an event", mock.initConverse(function (_converse) {
...@@ -46,15 +46,15 @@ ...@@ -46,15 +46,15 @@
_converse.off('connected', this.callback); _converse.off('connected', this.callback);
_converse.emit('connected'); _converse.emit('connected');
expect(this.callback.callCount, 1); expect(this.callback.calls.count(), 1);
expect(this.anotherCallback.callCount, 2); expect(this.anotherCallback.calls.count(), 2);
_converse.once('connected', this.neverCalled); _converse.once('connected', this.neverCalled);
_converse.off('connected', this.neverCalled); _converse.off('connected', this.neverCalled);
_converse.emit('connected'); _converse.emit('connected');
expect(this.callback.callCount, 1); expect(this.callback.calls.count(), 1);
expect(this.anotherCallback.callCount, 3); expect(this.anotherCallback.calls.count(), 3);
expect(this.neverCalled).not.toHaveBeenCalled(); expect(this.neverCalled).not.toHaveBeenCalled();
})); }));
}); });
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"converse-core", "converse-core",
"utils", "utils",
"mock", "mock",
"test_utils" "test-utils"
], factory); ], factory);
} (this, function ($, converse, utils, mock, test_utils) { } (this, function ($, converse, utils, mock, test_utils) {
"use strict"; "use strict";
...@@ -25,23 +25,18 @@ ...@@ -25,23 +25,18 @@
* </message * </message
*/ */
sinon.spy(utils, 'isHeadlineMessage'); sinon.spy(utils, 'isHeadlineMessage');
runs(function () { var stanza = $msg({
var stanza = $msg({ 'xmlns': 'jabber:client',
'xmlns': 'jabber:client', 'to': 'dummy@localhost',
'to': 'dummy@localhost', 'type': 'chat',
'type': 'chat', 'from': 'gapowa20102106@rds-rostov.ru/Adium',
'from': 'gapowa20102106@rds-rostov.ru/Adium', })
}) .c('nick', {'xmlns': "http://jabber.org/protocol/nick"}).t("-wwdmz").up()
.c('nick', {'xmlns': "http://jabber.org/protocol/nick"}).t("-wwdmz").up() .c('body').t('SORRY FOR THIS ADVERT');
.c('body').t('SORRY FOR THIS ADVERT'); _converse.connection._dataRecv(test_utils.createRequest(stanza));
_converse.connection._dataRecv(test_utils.createRequest(stanza)); expect(utils.isHeadlineMessage.called).toBeTruthy();
}); expect(utils.isHeadlineMessage.returned(false)).toBeTruthy();
waits(250); utils.isHeadlineMessage.restore();
runs(function () {
expect(utils.isHeadlineMessage.called).toBeTruthy();
expect(utils.isHeadlineMessage.returned(false)).toBeTruthy();
utils.isHeadlineMessage.restore();
});
})); }));
it("will open and display headline messages", mock.initConverse(function (_converse) { it("will open and display headline messages", mock.initConverse(function (_converse) {
...@@ -59,53 +54,43 @@ ...@@ -59,53 +54,43 @@
* </message> * </message>
*/ */
sinon.spy(utils, 'isHeadlineMessage'); sinon.spy(utils, 'isHeadlineMessage');
runs(function () { var stanza = $msg({
var stanza = $msg({ 'type': 'headline',
'type': 'headline', 'from': 'notify.example.com',
'from': 'notify.example.com', 'to': 'dummy@localhost',
'to': 'dummy@localhost', 'xml:lang': 'en'
'xml:lang': 'en' })
}) .c('subject').t('SIEVE').up()
.c('subject').t('SIEVE').up() .c('body').t('&lt;juliet@example.com&gt; You got mail.').up()
.c('body').t('&lt;juliet@example.com&gt; You got mail.').up() .c('x', {'xmlns': 'jabber:x:oob'})
.c('x', {'xmlns': 'jabber:x:oob'}) .c('url').t('imap://romeo@example.com/INBOX;UIDVALIDITY=385759043/;UID=18');
.c('url').t('imap://romeo@example.com/INBOX;UIDVALIDITY=385759043/;UID=18'); _converse.connection._dataRecv(test_utils.createRequest(stanza));
_converse.connection._dataRecv(test_utils.createRequest(stanza)); expect(
}); _.includes(
waits(250); _converse.chatboxviews.keys(),
runs(function () { 'notify.example.com')
expect( ).toBeTruthy();
_.includes( expect(utils.isHeadlineMessage.called).toBeTruthy();
_converse.chatboxviews.keys(), expect(utils.isHeadlineMessage.returned(true)).toBeTruthy();
'notify.example.com') utils.isHeadlineMessage.restore(); // unwraps
).toBeTruthy();
expect(utils.isHeadlineMessage.called).toBeTruthy();
expect(utils.isHeadlineMessage.returned(true)).toBeTruthy();
utils.isHeadlineMessage.restore(); // unwraps
});
})); }));
it("will not show a headline messages from a full JID if allow_non_roster_messaging is false", mock.initConverse(function (_converse) { it("will not show a headline messages from a full JID if allow_non_roster_messaging is false", mock.initConverse(function (_converse) {
_converse.allow_non_roster_messaging = false; _converse.allow_non_roster_messaging = false;
sinon.spy(utils, 'isHeadlineMessage'); sinon.spy(utils, 'isHeadlineMessage');
runs(function () { var stanza = $msg({
var stanza = $msg({ 'type': 'headline',
'type': 'headline', 'from': 'andre5114@jabber.snc.ru/Spark',
'from': 'andre5114@jabber.snc.ru/Spark', 'to': 'dummy@localhost',
'to': 'dummy@localhost', 'xml:lang': 'en'
'xml:lang': 'en' })
}) .c('nick').t('gpocy').up()
.c('nick').t('gpocy').up() .c('body').t('Здравствуйте друзья');
.c('body').t('Здравствуйте друзья'); _converse.connection._dataRecv(test_utils.createRequest(stanza));
_converse.connection._dataRecv(test_utils.createRequest(stanza)); expect(_.without('controlbox', _converse.chatboxviews.keys()).length).toBe(0);
}); expect(utils.isHeadlineMessage.called).toBeTruthy();
waits(250); expect(utils.isHeadlineMessage.returned(true)).toBeTruthy();
runs(function () { utils.isHeadlineMessage.restore(); // unwraps
expect(_.without('controlbox', _converse.chatboxviews.keys()).length).toBe(0);
expect(utils.isHeadlineMessage.called).toBeTruthy();
expect(utils.isHeadlineMessage.returned(true)).toBeTruthy();
utils.isHeadlineMessage.restore(); // unwraps
});
})); }));
}); });
})); }));
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "test_utils"], factory); define(["mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) { } (this, function (mock, converse, test_utils) {
"use strict"; "use strict";
var _ = converse.env._; var _ = converse.env._;
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
it("can be used to query for all archived messages", mock.initConverse(function (_converse) { it("can be used to query for all archived messages", mock.initConverse(function (_converse) {
var sent_stanza, IQ_id; var sent_stanza, IQ_id;
var sendIQ = _converse.connection.sendIQ; var sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').andCallFake(function (iq, callback, errback) { spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
sent_stanza = iq; sent_stanza = iq;
IQ_id = sendIQ.bind(this)(iq, callback, errback); IQ_id = sendIQ.bind(this)(iq, callback, errback);
}); });
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
it("can be used to query for all messages to/from a particular JID", mock.initConverse(function (_converse) { it("can be used to query for all messages to/from a particular JID", mock.initConverse(function (_converse) {
var sent_stanza, IQ_id; var sent_stanza, IQ_id;
var sendIQ = _converse.connection.sendIQ; var sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').andCallFake(function (iq, callback, errback) { spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
sent_stanza = iq; sent_stanza = iq;
IQ_id = sendIQ.bind(this)(iq, callback, errback); IQ_id = sendIQ.bind(this)(iq, callback, errback);
}); });
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
it("can be used to query for all messages in a certain timespan", mock.initConverse(function (_converse) { it("can be used to query for all messages in a certain timespan", mock.initConverse(function (_converse) {
var sent_stanza, IQ_id; var sent_stanza, IQ_id;
var sendIQ = _converse.connection.sendIQ; var sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').andCallFake(function (iq, callback, errback) { spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
sent_stanza = iq; sent_stanza = iq;
IQ_id = sendIQ.bind(this)(iq, callback, errback); IQ_id = sendIQ.bind(this)(iq, callback, errback);
}); });
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
it("can be used to query for all messages after a certain time", mock.initConverse(function (_converse) { it("can be used to query for all messages after a certain time", mock.initConverse(function (_converse) {
var sent_stanza, IQ_id; var sent_stanza, IQ_id;
var sendIQ = _converse.connection.sendIQ; var sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').andCallFake(function (iq, callback, errback) { spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
sent_stanza = iq; sent_stanza = iq;
IQ_id = sendIQ.bind(this)(iq, callback, errback); IQ_id = sendIQ.bind(this)(iq, callback, errback);
}); });
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
it("can be used to query for a limited set of results", mock.initConverse(function (_converse) { it("can be used to query for a limited set of results", mock.initConverse(function (_converse) {
var sent_stanza, IQ_id; var sent_stanza, IQ_id;
var sendIQ = _converse.connection.sendIQ; var sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').andCallFake(function (iq, callback, errback) { spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
sent_stanza = iq; sent_stanza = iq;
IQ_id = sendIQ.bind(this)(iq, callback, errback); IQ_id = sendIQ.bind(this)(iq, callback, errback);
}); });
...@@ -169,7 +169,7 @@ ...@@ -169,7 +169,7 @@
it("can be used to page through results", mock.initConverse(function (_converse) { it("can be used to page through results", mock.initConverse(function (_converse) {
var sent_stanza, IQ_id; var sent_stanza, IQ_id;
var sendIQ = _converse.connection.sendIQ; var sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').andCallFake(function (iq, callback, errback) { spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
sent_stanza = iq; sent_stanza = iq;
IQ_id = sendIQ.bind(this)(iq, callback, errback); IQ_id = sendIQ.bind(this)(iq, callback, errback);
}); });
...@@ -206,7 +206,7 @@ ...@@ -206,7 +206,7 @@
it("accepts \"before\" with an empty string as value to reverse the order", mock.initConverse(function (_converse) { it("accepts \"before\" with an empty string as value to reverse the order", mock.initConverse(function (_converse) {
var sent_stanza, IQ_id; var sent_stanza, IQ_id;
var sendIQ = _converse.connection.sendIQ; var sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').andCallFake(function (iq, callback, errback) { spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
sent_stanza = iq; sent_stanza = iq;
IQ_id = sendIQ.bind(this)(iq, callback, errback); IQ_id = sendIQ.bind(this)(iq, callback, errback);
}); });
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
} }
var sent_stanza, IQ_id; var sent_stanza, IQ_id;
var sendIQ = _converse.connection.sendIQ; var sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').andCallFake(function (iq, callback, errback) { spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
sent_stanza = iq; sent_stanza = iq;
IQ_id = sendIQ.bind(this)(iq, callback, errback); IQ_id = sendIQ.bind(this)(iq, callback, errback);
}); });
...@@ -280,7 +280,7 @@ ...@@ -280,7 +280,7 @@
} }
var sent_stanza, IQ_id; var sent_stanza, IQ_id;
var sendIQ = _converse.connection.sendIQ; var sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').andCallFake(function (iq, callback, errback) { spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
sent_stanza = iq; sent_stanza = iq;
IQ_id = sendIQ.bind(this)(iq, callback, errback); IQ_id = sendIQ.bind(this)(iq, callback, errback);
}); });
...@@ -352,7 +352,7 @@ ...@@ -352,7 +352,7 @@
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
expect(callback).toHaveBeenCalled(); expect(callback).toHaveBeenCalled();
var args = callback.argsForCall[0]; var args = callback.calls.argsFor(0);
expect(args[0].length).toBe(2); expect(args[0].length).toBe(2);
expect(args[0][0].outerHTML).toBe(msg1.nodeTree.outerHTML); expect(args[0][0].outerHTML).toBe(msg1.nodeTree.outerHTML);
expect(args[0][1].outerHTML).toBe(msg2.nodeTree.outerHTML); expect(args[0][1].outerHTML).toBe(msg2.nodeTree.outerHTML);
...@@ -370,17 +370,17 @@ ...@@ -370,17 +370,17 @@
it("is set once server support for MAM has been confirmed", mock.initConverse(function (_converse) { it("is set once server support for MAM has been confirmed", mock.initConverse(function (_converse) {
var sent_stanza, IQ_id; var sent_stanza, IQ_id;
var sendIQ = _converse.connection.sendIQ; var sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').andCallFake(function (iq, callback, errback) { spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
sent_stanza = iq; sent_stanza = iq;
IQ_id = sendIQ.bind(this)(iq, callback, errback); IQ_id = sendIQ.bind(this)(iq, callback, errback);
}); });
spyOn(_converse, 'onMAMPreferences').andCallThrough(); spyOn(_converse, 'onMAMPreferences').and.callThrough();
_converse.message_archiving = 'never'; _converse.message_archiving = 'never';
var feature = new _converse.Feature({ var feature = new _converse.Feature({
'var': Strophe.NS.MAM 'var': Strophe.NS.MAM
}); });
spyOn(feature, 'save').andCallFake(feature.set); // Save will complain about a url not being set spyOn(feature, 'save').and.callFake(feature.set); // Save will complain about a url not being set
_converse.features.onFeatureAdded(feature); _converse.features.onFeatureAdded(feature);
expect(_converse.connection.sendIQ).toHaveBeenCalled(); expect(_converse.connection.sendIQ).toHaveBeenCalled();
...@@ -407,7 +407,7 @@ ...@@ -407,7 +407,7 @@
expect(_converse.onMAMPreferences).toHaveBeenCalled(); expect(_converse.onMAMPreferences).toHaveBeenCalled();
expect(_converse.connection.sendIQ.callCount).toBe(2); expect(_converse.connection.sendIQ.calls.count()).toBe(2);
expect(sent_stanza.toString()).toBe( expect(sent_stanza.toString()).toBe(
"<iq type='set' xmlns='jabber:client' id='"+IQ_id+"'>"+ "<iq type='set' xmlns='jabber:client' id='"+IQ_id+"'>"+
"<prefs xmlns='urn:xmpp:mam:0' default='never'>"+ "<prefs xmlns='urn:xmpp:mam:0' default='never'>"+
......
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "test_utils"], factory); define(["mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) { } (this, function (mock, converse, test_utils) {
var _ = converse.env._; var _ = converse.env._;
var $msg = converse.env.$msg; var $msg = converse.env.$msg;
......
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "test_utils", "utils"], factory); define(["mock", "converse-core", "test-utils", "utils"], factory);
} (this, function (mock, converse, test_utils, utils) { } (this, function (mock, converse, test_utils, utils) {
"use strict"; "use strict";
var _ = converse.env._; var _ = converse.env._;
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
// TODO: not yet testing show_desktop_notifications setting // TODO: not yet testing show_desktop_notifications setting
test_utils.createContacts(_converse, 'current'); test_utils.createContacts(_converse, 'current');
spyOn(_converse, 'showMessageNotification'); spyOn(_converse, 'showMessageNotification');
spyOn(_converse, 'areDesktopNotificationsEnabled').andReturn(true); spyOn(_converse, 'areDesktopNotificationsEnabled').and.returnValue(true);
var message = 'This message will show a desktop notification'; var message = 'This message will show a desktop notification';
var sender_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost', var sender_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost',
...@@ -46,8 +46,8 @@ ...@@ -46,8 +46,8 @@
}; };
}; };
} }
spyOn(_converse, 'showMessageNotification').andCallThrough(); spyOn(_converse, 'showMessageNotification').and.callThrough();
spyOn(_converse, 'areDesktopNotificationsEnabled').andReturn(true); spyOn(_converse, 'areDesktopNotificationsEnabled').and.returnValue(true);
var message = 'dummy: This message will show a desktop notification'; var message = 'dummy: This message will show a desktop notification';
var nick = mock.chatroom_names[0], var nick = mock.chatroom_names[0],
...@@ -66,56 +66,46 @@ ...@@ -66,56 +66,46 @@
})); }));
it("is shown for headline messages", mock.initConverse(function (_converse) { it("is shown for headline messages", mock.initConverse(function (_converse) {
spyOn(_converse, 'showMessageNotification').andCallThrough(); spyOn(_converse, 'showMessageNotification').and.callThrough();
spyOn(_converse, 'areDesktopNotificationsEnabled').andReturn(true); spyOn(_converse, 'areDesktopNotificationsEnabled').and.returnValue(true);
runs(function () { var stanza = $msg({
var stanza = $msg({ 'type': 'headline',
'type': 'headline', 'from': 'notify.example.com',
'from': 'notify.example.com', 'to': 'dummy@localhost',
'to': 'dummy@localhost', 'xml:lang': 'en'
'xml:lang': 'en' })
}) .c('subject').t('SIEVE').up()
.c('subject').t('SIEVE').up() .c('body').t('&lt;juliet@example.com&gt; You got mail.').up()
.c('body').t('&lt;juliet@example.com&gt; You got mail.').up() .c('x', {'xmlns': 'jabber:x:oob'})
.c('x', {'xmlns': 'jabber:x:oob'}) .c('url').t('imap://romeo@example.com/INBOX;UIDVALIDITY=385759043/;UID=18');
.c('url').t('imap://romeo@example.com/INBOX;UIDVALIDITY=385759043/;UID=18'); _converse.connection._dataRecv(test_utils.createRequest(stanza));
_converse.connection._dataRecv(test_utils.createRequest(stanza)); expect(
}); _.includes(_converse.chatboxviews.keys(),
waits(250); 'notify.example.com')
runs(function () { ).toBeTruthy();
expect( expect(_converse.showMessageNotification).toHaveBeenCalled();
_.includes(_converse.chatboxviews.keys(),
'notify.example.com')
).toBeTruthy();
expect(_converse.showMessageNotification).toHaveBeenCalled();
});
})); }));
it("is not shown for full JID headline messages if allow_non_roster_messaging is false", mock.initConverse(function (_converse) { it("is not shown for full JID headline messages if allow_non_roster_messaging is false", mock.initConverse(function (_converse) {
_converse.allow_non_roster_messaging = false; _converse.allow_non_roster_messaging = false;
spyOn(_converse, 'showMessageNotification').andCallThrough(); spyOn(_converse, 'showMessageNotification').and.callThrough();
spyOn(_converse, 'areDesktopNotificationsEnabled').andReturn(true); spyOn(_converse, 'areDesktopNotificationsEnabled').and.returnValue(true);
runs(function () { var stanza = $msg({
var stanza = $msg({ 'type': 'headline',
'type': 'headline', 'from': 'someone@notify.example.com',
'from': 'someone@notify.example.com', 'to': 'dummy@localhost',
'to': 'dummy@localhost', 'xml:lang': 'en'
'xml:lang': 'en' })
}) .c('subject').t('SIEVE').up()
.c('subject').t('SIEVE').up() .c('body').t('&lt;juliet@example.com&gt; You got mail.').up()
.c('body').t('&lt;juliet@example.com&gt; You got mail.').up() .c('x', {'xmlns': 'jabber:x:oob'})
.c('x', {'xmlns': 'jabber:x:oob'}) .c('url').t('imap://romeo@example.com/INBOX;UIDVALIDITY=385759043/;UID=18');
.c('url').t('imap://romeo@example.com/INBOX;UIDVALIDITY=385759043/;UID=18'); _converse.connection._dataRecv(test_utils.createRequest(stanza));
_converse.connection._dataRecv(test_utils.createRequest(stanza)); expect(
}); _.includes(_converse.chatboxviews.keys(),
waits(250); 'someone@notify.example.com')
runs(function () { ).toBeFalsy();
expect( expect(_converse.showMessageNotification).not.toHaveBeenCalled();
_.includes(_converse.chatboxviews.keys(),
'someone@notify.example.com')
).toBeFalsy();
expect(_converse.showMessageNotification).not.toHaveBeenCalled();
});
})); }));
it("is shown when a user changes their chat state (if show_chatstate_notifications is true)", mock.initConverse(function (_converse) { it("is shown when a user changes their chat state (if show_chatstate_notifications is true)", mock.initConverse(function (_converse) {
...@@ -123,7 +113,7 @@ ...@@ -123,7 +113,7 @@
_converse.show_chatstate_notifications = true; _converse.show_chatstate_notifications = true;
test_utils.createContacts(_converse, 'current'); test_utils.createContacts(_converse, 'current');
spyOn(_converse, 'areDesktopNotificationsEnabled').andReturn(true); spyOn(_converse, 'areDesktopNotificationsEnabled').and.returnValue(true);
spyOn(_converse, 'showChatStateNotification'); spyOn(_converse, 'showChatStateNotification');
var jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@localhost'; var jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@localhost';
_converse.roster.get(jid).set('chat_status', 'busy'); // This will emit 'contactStatusChanged' _converse.roster.get(jid).set('chat_status', 'busy'); // This will emit 'contactStatusChanged'
...@@ -135,7 +125,7 @@ ...@@ -135,7 +125,7 @@
describe("When a new contact request is received", function () { describe("When a new contact request is received", function () {
it("an HTML5 Notification is received", mock.initConverse(function (_converse) { it("an HTML5 Notification is received", mock.initConverse(function (_converse) {
spyOn(_converse, 'areDesktopNotificationsEnabled').andReturn(true); spyOn(_converse, 'areDesktopNotificationsEnabled').and.returnValue(true);
spyOn(_converse, 'showContactRequestNotification'); spyOn(_converse, 'showContactRequestNotification');
_converse.emit('contactRequest', {'fullname': 'Peter Parker', 'jid': 'peter@parker.com'}); _converse.emit('contactRequest', {'fullname': 'Peter Parker', 'jid': 'peter@parker.com'});
expect(_converse.areDesktopNotificationsEnabled).toHaveBeenCalled(); expect(_converse.areDesktopNotificationsEnabled).toHaveBeenCalled();
......
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "test_utils"], factory); define(["mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) { } (this, function (mock, converse, test_utils) {
var $ = converse.env.jQuery; var $ = converse.env.jQuery;
var Strophe = converse.env.Strophe; var Strophe = converse.env.Strophe;
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
spyOn(_converse.connection, 'send'); spyOn(_converse.connection, 'send');
chatbox.set('otr_status', 1); // Set OTR status to UNVERIFIED, to mock an encrypted session chatbox.set('otr_status', 1); // Set OTR status to UNVERIFIED, to mock an encrypted session
chatbox.trigger('sendMessage', new _converse.Message({ message: msgtext })); chatbox.trigger('sendMessage', new _converse.Message({ message: msgtext }));
var $sent = $(_converse.connection.send.argsForCall[0][0].tree()); var $sent = $(_converse.connection.send.calls.argsFor(0)[0].tree());
expect($sent.find('body').siblings('private').length).toBe(1); expect($sent.find('body').siblings('private').length).toBe(1);
expect($sent.find('private').length).toBe(1); expect($sent.find('private').length).toBe(1);
expect($sent.find('private').attr('xmlns')).toBe('urn:xmpp:carbons:2'); expect($sent.find('private').attr('xmlns')).toBe('urn:xmpp:carbons:2');
......
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "test_utils", "converse-ping"], factory); define(["mock", "converse-core", "test-utils", "converse-ping"], factory);
} (this, function (mock, test_utils) { } (this, function (mock, test_utils) {
"use strict"; "use strict";
...@@ -7,16 +7,16 @@ ...@@ -7,16 +7,16 @@
describe("Ping and pong handlers", function () { describe("Ping and pong handlers", function () {
it("are registered when _converse.js is connected", mock.initConverse(function (_converse) { it("are registered when _converse.js is connected", mock.initConverse(function (_converse) {
spyOn(_converse, 'registerPingHandler').andCallThrough(); spyOn(_converse, 'registerPingHandler').and.callThrough();
spyOn(_converse, 'registerPongHandler').andCallThrough(); spyOn(_converse, 'registerPongHandler').and.callThrough();
_converse.emit('connected'); _converse.emit('connected');
expect(_converse.registerPingHandler).toHaveBeenCalled(); expect(_converse.registerPingHandler).toHaveBeenCalled();
expect(_converse.registerPongHandler).toHaveBeenCalled(); expect(_converse.registerPongHandler).toHaveBeenCalled();
})); }));
it("are registered when _converse.js reconnected", mock.initConverse(function (_converse) { it("are registered when _converse.js reconnected", mock.initConverse(function (_converse) {
spyOn(_converse, 'registerPingHandler').andCallThrough(); spyOn(_converse, 'registerPingHandler').and.callThrough();
spyOn(_converse, 'registerPongHandler').andCallThrough(); spyOn(_converse, 'registerPongHandler').and.callThrough();
_converse.emit('reconnected'); _converse.emit('reconnected');
expect(_converse.registerPingHandler).toHaveBeenCalled(); expect(_converse.registerPingHandler).toHaveBeenCalled();
expect(_converse.registerPongHandler).toHaveBeenCalled(); expect(_converse.registerPongHandler).toHaveBeenCalled();
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
it("is sent out when _converse.js pings a server", mock.initConverse(function (_converse) { it("is sent out when _converse.js pings a server", mock.initConverse(function (_converse) {
var sent_stanza, IQ_id; var sent_stanza, IQ_id;
var sendIQ = _converse.connection.sendIQ; var sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').andCallFake(function (iq, callback, errback) { spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
sent_stanza = iq; sent_stanza = iq;
IQ_id = sendIQ.bind(this)(iq, callback, errback); IQ_id = sendIQ.bind(this)(iq, callback, errback);
}); });
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"jquery", "jquery",
"converse-core", "converse-core",
"mock", "mock",
"test_utils", "test-utils",
"lodash"], factory); "lodash"], factory);
} (this, function ($, converse, mock, test_utils, _) { } (this, function ($, converse, mock, test_utils, _) {
"use strict"; "use strict";
......
This diff is collapsed.
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "test_utils"], factory); define(["mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) { } (this, function (mock, converse, test_utils) {
var $ = converse.env.jQuery; var $ = converse.env.jQuery;
var Strophe = converse.env.Strophe; var Strophe = converse.env.Strophe;
...@@ -8,44 +8,40 @@ ...@@ -8,44 +8,40 @@
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.initConverse(function (_converse) {
runs(test_utils.openControlBox); test_utils.openControlBox();
waits(50); var cbview = _converse.chatboxviews.get('controlbox');
runs(function () { expect(cbview.$('#controlbox-tabs li').length).toBe(1);
var cbview = _converse.chatboxviews.get('controlbox'); expect(cbview.$('#controlbox-tabs li').text().trim()).toBe("Sign in");
expect(cbview.$('#controlbox-tabs li').length).toBe(1);
expect(cbview.$('#controlbox-tabs li').text().trim()).toBe("Sign in"); }, { auto_login: false,
}); allow_registration: false,
}, { auto_login: false, }));
allow_registration: false,
}));
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.initConverse(function (_converse) {
var cbview = _converse.chatboxviews.get('controlbox'); var cbview = _converse.chatboxviews.get('controlbox');
runs(test_utils.openControlBox); test_utils.openControlBox();
waits(50); var $tabs = cbview.$('#controlbox-tabs');
runs(function () { var $panels = cbview.$('.controlbox-panes');
var $tabs = cbview.$('#controlbox-tabs'); var $login = $panels.children().first();
var $panels = cbview.$('.controlbox-panes'); var $registration = $panels.children().last();
var $login = $panels.children().first(); expect($tabs.find('li').first().text()).toBe('Sign in');
var $registration = $panels.children().last(); expect($tabs.find('li').last().text()).toBe('Register');
expect($tabs.find('li').first().text()).toBe('Sign in');
expect($tabs.find('li').last().text()).toBe('Register'); spyOn(cbview, 'switchTab').and.callThrough();
cbview.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
spyOn(cbview, 'switchTab').andCallThrough(); $tabs.find('li').last().find('a').click(); // Click the Register tab
cbview.delegateEvents(); // We need to rebind all events otherwise our spy won't be called expect($login.is(':visible')).toBe(false);
$tabs.find('li').last().find('a').click(); // Click the Register tab expect($registration.is(':visible')).toBe(true);
expect($login.is(':visible')).toBe(false); expect(cbview.switchTab).toHaveBeenCalled();
expect($registration.is(':visible')).toBe(true);
expect(cbview.switchTab).toHaveBeenCalled(); }, { auto_login: false,
}); allow_registration: true,
}, { auto_login: false, }));
allow_registration: true,
}));
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.initConverse(function (_converse) {
var cbview = _converse.chatboxviews.get('controlbox'); var cbview = _converse.chatboxviews.get('controlbox');
var registerview = cbview.registerpanel; var registerview = cbview.registerpanel;
spyOn(registerview, 'onProviderChosen').andCallThrough(); spyOn(registerview, 'onProviderChosen').and.callThrough();
registerview.delegateEvents(); // We need to rebind all events otherwise our spy won't be called registerview.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
spyOn(_converse.connection, 'connect'); spyOn(_converse.connection, 'connect');
var $tabs = cbview.$('#controlbox-tabs'); var $tabs = cbview.$('#controlbox-tabs');
...@@ -72,12 +68,12 @@ ...@@ -72,12 +68,12 @@
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;
spyOn(registerview, 'onProviderChosen').andCallThrough(); spyOn(registerview, 'onProviderChosen').and.callThrough();
spyOn(registerview, 'getRegistrationFields').andCallThrough(); spyOn(registerview, 'getRegistrationFields').and.callThrough();
spyOn(registerview, 'onRegistrationFields').andCallThrough(); spyOn(registerview, 'onRegistrationFields').and.callThrough();
spyOn(registerview, 'renderRegistrationForm').andCallThrough(); spyOn(registerview, 'renderRegistrationForm').and.callThrough();
registerview.delegateEvents(); // We need to rebind all events otherwise our spy won't be called registerview.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
spyOn(_converse.connection, 'connect').andCallThrough(); spyOn(_converse.connection, 'connect').and.callThrough();
expect(registerview._registering).toBeFalsy(); expect(registerview._registering).toBeFalsy();
expect(_converse.connection.connected).toBeFalsy(); expect(_converse.connection.connected).toBeFalsy();
...@@ -120,12 +116,12 @@ ...@@ -120,12 +116,12 @@
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;
spyOn(registerview, 'onProviderChosen').andCallThrough(); spyOn(registerview, 'onProviderChosen').and.callThrough();
spyOn(registerview, 'getRegistrationFields').andCallThrough(); spyOn(registerview, 'getRegistrationFields').and.callThrough();
spyOn(registerview, 'onRegistrationFields').andCallThrough(); spyOn(registerview, 'onRegistrationFields').and.callThrough();
spyOn(registerview, 'renderRegistrationForm').andCallThrough(); spyOn(registerview, 'renderRegistrationForm').and.callThrough();
registerview.delegateEvents(); // We need to rebind all events otherwise our spy won't be called registerview.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
spyOn(_converse.connection, 'connect').andCallThrough(); spyOn(_converse.connection, 'connect').and.callThrough();
registerview.$('input[name=domain]').val('conversejs.org'); registerview.$('input[name=domain]').val('conversejs.org');
registerview.$('input[type=submit]').click(); registerview.$('input[type=submit]').click();
...@@ -158,7 +154,7 @@ ...@@ -158,7 +154,7 @@
registerview.$('input[type=submit]').click(); registerview.$('input[type=submit]').click();
expect(_converse.connection.send).toHaveBeenCalled(); expect(_converse.connection.send).toHaveBeenCalled();
var $stanza = $(_converse.connection.send.argsForCall[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, }, { auto_login: false,
...@@ -169,12 +165,12 @@ ...@@ -169,12 +165,12 @@
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;
spyOn(registerview, 'onProviderChosen').andCallThrough(); spyOn(registerview, 'onProviderChosen').and.callThrough();
spyOn(registerview, 'getRegistrationFields').andCallThrough(); spyOn(registerview, 'getRegistrationFields').and.callThrough();
spyOn(registerview, 'onRegistrationFields').andCallThrough(); spyOn(registerview, 'onRegistrationFields').and.callThrough();
spyOn(registerview, 'renderRegistrationForm').andCallThrough(); spyOn(registerview, 'renderRegistrationForm').and.callThrough();
registerview.delegateEvents(); // We need to rebind all events otherwise our spy won't be called registerview.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
spyOn(_converse.connection, 'connect').andCallThrough(); spyOn(_converse.connection, 'connect').and.callThrough();
registerview.$('input[name=domain]').val('conversejs.org'); registerview.$('input[name=domain]').val('conversejs.org');
registerview.$('input[type=submit]').click(); registerview.$('input[type=submit]').click();
...@@ -209,7 +205,7 @@ ...@@ -209,7 +205,7 @@
registerview.$('input[type=submit]').click(); registerview.$('input[type=submit]').click();
expect(_converse.connection.send).toHaveBeenCalled(); expect(_converse.connection.send).toHaveBeenCalled();
var $stanza = $(_converse.connection.send.argsForCall[0][0].tree()); var $stanza = $(_converse.connection.send.calls.argsFor(0)[0].tree());
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');
......
(function (root, factory) { (function (root, factory) {
define(["converse-core"], factory); define(["jasmine-html", "converse-core"], factory);
} (this, function (converse) { } (this, function (jasmine, converse) {
var utils = converse.env.utils, var utils = converse.env.utils,
_ = converse.env._; _ = converse.env._;
......
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "test_utils"], factory); define(["mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) { } (this, function (mock, converse, test_utils) {
var $ = converse.env.jQuery; var $ = converse.env.jQuery;
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
it("won't send <show>online</show> when setting a custom status message", mock.initConverse(function (_converse) { it("won't send <show>online</show> when setting a custom status message", mock.initConverse(function (_converse) {
_converse.xmppstatus.save({'status': 'online'}); _converse.xmppstatus.save({'status': 'online'});
spyOn(_converse.xmppstatus, 'setStatusMessage').andCallThrough(); spyOn(_converse.xmppstatus, 'setStatusMessage').and.callThrough();
spyOn(_converse.connection, 'send'); spyOn(_converse.connection, 'send');
_converse.xmppstatus.setStatusMessage("I'm also happy!"); _converse.xmppstatus.setStatusMessage("I'm also happy!");
expect(_converse.connection.send).toHaveBeenCalled(); expect(_converse.connection.send).toHaveBeenCalled();
var $stanza = $(_converse.connection.send.argsForCall[0][0].tree()); var $stanza = $(_converse.connection.send.calls.argsFor(0)[0].tree());
expect($stanza.children().length).toBe(2); expect($stanza.children().length).toBe(2);
expect($stanza.children('status').length).toBe(1); expect($stanza.children('status').length).toBe(1);
expect($stanza.children('status').text()).toBe("I'm also happy!"); expect($stanza.children('status').text()).toBe("I'm also happy!");
......
...@@ -21,6 +21,7 @@ require.config({ ...@@ -21,6 +21,7 @@ require.config({
"backbone.browserStorage": "node_modules/backbone.browserStorage/backbone.browserStorage", "backbone.browserStorage": "node_modules/backbone.browserStorage/backbone.browserStorage",
"backbone.overview": "node_modules/backbone.overview/backbone.overview", "backbone.overview": "node_modules/backbone.overview/backbone.overview",
"eventemitter": "node_modules/otr/build/dep/eventemitter", "eventemitter": "node_modules/otr/build/dep/eventemitter",
"es6-promise": "node_modules/es6-promise/dist/es6-promise",
"jquery": "node_modules/jquery/dist/jquery", "jquery": "node_modules/jquery/dist/jquery",
"jquery-private": "src/jquery-private", "jquery-private": "src/jquery-private",
"jquery.browser": "node_modules/jquery.browser/dist/jquery.browser", "jquery.browser": "node_modules/jquery.browser/dist/jquery.browser",
......
...@@ -4,12 +4,16 @@ ...@@ -4,12 +4,16 @@
<head> <head>
<title>Converse.js Tests</title> <title>Converse.js Tests</title>
<meta name="description" content="Converse.js: A chat client for your website" /> <meta name="description" content="Converse.js: A chat client for your website" />
<link rel="shortcut icon" type="image/png" href="components/jasmine/images/jasmine_favicon.png"> <link rel="shortcut icon" type="image/png" href="node_modules/jasmine-core/images/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" media="screen" href="node_modules/jasmine-core/lib/jasmine-core/jasmine.css">
<link rel="stylesheet" type="text/css" media="screen" href="css/jasmine.css"> <link rel="stylesheet" type="text/css" media="screen" href="css/jasmine.css">
<link type="text/css" rel="stylesheet" media="screen" href="css/theme.css" /> <link type="text/css" rel="stylesheet" media="screen" href="css/theme.css" />
<link type="text/css" rel="stylesheet" media="screen" href="css/converse.css" /> <link type="text/css" rel="stylesheet" media="screen" href="css/converse.css" />
<script src="src/config.js"></script> <script src="src/config.js"></script>
<script data-main="tests/main" src="node_modules/requirejs/require.js"></script> <script data-main="tests/runner" src="node_modules/requirejs/require.js"></script>
<style> <style>
.tests-brand-heading { .tests-brand-heading {
margin-top: 1em; margin-top: 1em;
...@@ -21,7 +25,8 @@ ...@@ -21,7 +25,8 @@
<body> <body>
<div id="header_wrap" class="outer"> <div id="header_wrap" class="outer">
<header class="inner"> <header class="inner">
<h1 class="brand-heading tests-brand-heading"><i class="icon-conversejs"></i> Converse.js</h1> <h1 class="brand-heading tests-brand-heading">
<i class="icon-conversejs"></i> Converse.js</h1>
<h2 id="project_tagline">Tests</h2> <h2 id="project_tagline">Tests</h2>
</header> </header>
</div> </div>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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