Commit 2a593a03 authored by JC Brand's avatar JC Brand

Add a test spec for autocompletion

parent 5ded3b6c
(function (root, factory) {
define([
"jasmine",
"mock",
"test-utils"
], factory);
} (this, function (jasmine, mock, test_utils) {
"use strict";
const _ = converse.env._;
const $iq = converse.env.$iq;
const $msg = converse.env.$msg;
const $pres = converse.env.$pres;
const Strophe = converse.env.Strophe;
const u = converse.env.utils;
const sizzle = converse.env.sizzle;
return describe("A groupchat textarea", function () {
it("autocompletes when the user presses tab",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy')
.then(() => {
const view = _converse.chatboxviews.get('lounge@localhost');
expect(view.model.occupants.length).toBe(1);
const presence = $pres({
'to': 'dummy@localhost/resource',
'from': 'lounge@localhost/some1'
})
.c('x', {xmlns: Strophe.NS.MUC_USER})
.c('item', {
'affiliation': 'none',
'jid': 'some1@localhost/resource',
'role': 'participant'
});
_converse.connection._dataRecv(test_utils.createRequest(presence));
expect(view.model.occupants.length).toBe(2);
const textarea = view.el.querySelector('textarea.chat-textarea');
textarea.value = "hello som";
// Press tab
view.keyPressed({
target: textarea,
preventDefault: _.noop,
keyCode: 9
});
expect(view.el.querySelector('.suggestion-box__results').hidden).toBeFalsy();
done();
}).catch(_.partial(console.error, _));
}));
});
}));
...@@ -201,6 +201,7 @@ var specs = [ ...@@ -201,6 +201,7 @@ var specs = [
"spec/user-details-modal", "spec/user-details-modal",
"spec/messages", "spec/messages",
"spec/chatroom", "spec/chatroom",
"spec/autocomplete",
"spec/minchats", "spec/minchats",
"spec/notification", "spec/notification",
"spec/login", "spec/login",
......
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