Fix failing tests

This commit is contained in:
JC Brand 2022-01-27 18:24:06 +01:00
parent c83cc69cef
commit d06761e2a8
4 changed files with 9 additions and 4 deletions

View File

@ -64,8 +64,9 @@ describe("Chatboxes", function () {
preventDefault: function preventDefault () {},
keyCode: 13 // Enter
});
expect(window.confirm).toHaveBeenCalled();
await u.waitUntil(() => window.confirm.calls.count() === 1);
await u.waitUntil(() => sizzle('converse-chat-message', view).length === 0);
expect(true).toBe(true);
}));
@ -922,6 +923,7 @@ describe("Chatboxes", function () {
preventDefault: function preventDefault () {},
keyCode: 13
});
await u.waitUntil(() => window.confirm.calls.count() === 1);
expect(window.confirm).toHaveBeenCalledWith('Are you sure you want to clear the messages from this conversation?');
await u.waitUntil(() => view.model.messages.length === 0);
await u.waitUntil(() => !view.querySelectorAll('.chat-msg__body').length);

View File

@ -51,9 +51,9 @@ describe("A Chat Message", function () {
preventDefault: function preventDefault () {},
keyCode: 13 // Enter
});
expect(_converse.connection.send).toHaveBeenCalled();
await u.waitUntil(() => view.querySelector('.chat-msg__text').textContent.replace(/<!-.*?->/g, '') === new_text);
expect(_converse.connection.send).toHaveBeenCalled();
const msg = _converse.connection.send.calls.all()[0].args[0];
expect(Strophe.serialize(msg))
.toBe(`<message from="romeo@montague.lit/orchard" id="${msg.getAttribute("id")}" `+
@ -202,12 +202,14 @@ describe("A Chat Message", function () {
await u.waitUntil(() => u.hasClass('correcting', view.querySelector('.chat-msg')));
spyOn(_converse.connection, 'send');
textarea.value = 'But soft, what light through yonder window breaks?';
const text = 'But soft, what light through yonder window breaks?';
textarea.value = text;
message_form.onKeyDown({
target: textarea,
preventDefault: function preventDefault () {},
keyCode: 13 // Enter
});
await u.waitUntil(() => view.querySelector('.chat-msg__text').textContent.replace(/<!-.*?->/g, '') === text);
expect(_converse.connection.send).toHaveBeenCalled();
const msg = _converse.connection.send.calls.all()[0].args[0];

View File

@ -203,10 +203,10 @@ describe("A Groupchat Message", function () {
preventDefault: function preventDefault () {},
keyCode: 13 // Enter
});
expect(_converse.connection.send).toHaveBeenCalled();
await u.waitUntil(() => Array.from(view.querySelectorAll('.chat-msg__text'))
.filter(m => m.textContent.replace(/<!-.*?->/g, '') === new_text).length);
expect(_converse.connection.send).toHaveBeenCalled();
const msg = _converse.connection.send.calls.all()[0].args[0];
expect(Strophe.serialize(msg))
.toBe(`<message from="romeo@montague.lit/orchard" id="${msg.getAttribute("id")}" `+

View File

@ -2661,6 +2661,7 @@ describe("Groupchats", function () {
preventDefault: function preventDefault () {},
keyCode: 13
});
await u.waitUntil(() => window.confirm.calls.count() === 1);
expect(window.confirm).toHaveBeenCalledWith('Are you sure you want to clear the messages from this conversation?');
}));