Minor idiomatic changes

This commit is contained in:
JC Brand 2018-08-14 11:58:34 +02:00
parent b6f4f05b9e
commit 33cd23c529
2 changed files with 49 additions and 48 deletions

View File

@ -1491,7 +1491,7 @@
var chatbox = _converse.chatboxes.get(sender_jid); var chatbox = _converse.chatboxes.get(sender_jid);
var chatboxview = _converse.chatboxviews.get(sender_jid); var chatboxview = _converse.chatboxviews.get(sender_jid);
var msgsIndicatorSelector = 'a.open-chat:contains("' + chatbox.get('fullname') + '") .msgs-indicator'; var msgsIndicatorSelector = 'a.open-chat:contains("' + chatbox.get('fullname') + '") .msgs-indicator';
var selectMsgsIndicator = function () { return $($(_converse.rosterview.el).find(msgsIndicatorSelector)); }; var selectMsgsIndicator = () => $(_converse.rosterview.el).find(msgsIndicatorSelector);
var msgFactory = function () { var msgFactory = function () {
return test_utils.createChatMessage(_converse, sender_jid, 'This message will be received as unread, but eventually will be read'); return test_utils.createChatMessage(_converse, sender_jid, 'This message will be received as unread, but eventually will be read');
}; };
@ -1527,7 +1527,7 @@
return test_utils.createChatMessage(_converse, sender_jid, 'This message will be received as unread, but eventually will be read'); return test_utils.createChatMessage(_converse, sender_jid, 'This message will be received as unread, but eventually will be read');
}; };
var msgsIndicatorSelector = 'a.open-chat:contains("' + chatbox.get('fullname') + '") .msgs-indicator', var msgsIndicatorSelector = 'a.open-chat:contains("' + chatbox.get('fullname') + '") .msgs-indicator',
selectMsgsIndicator = function () { return $($(_converse.rosterview.el).find(msgsIndicatorSelector)); }; selectMsgsIndicator = () => $(_converse.rosterview.el).find(msgsIndicatorSelector);
chatbox.save('scrolled', true); chatbox.save('scrolled', true);
@ -1559,7 +1559,7 @@
return test_utils.createChatMessage(_converse, sender_jid, 'This message will be received as unread, but eventually will be read'); return test_utils.createChatMessage(_converse, sender_jid, 'This message will be received as unread, but eventually will be read');
}; };
var msgsIndicatorSelector = 'a.open-chat:contains("' + chatbox.get('fullname') + '") .msgs-indicator', var msgsIndicatorSelector = 'a.open-chat:contains("' + chatbox.get('fullname') + '") .msgs-indicator',
selectMsgsIndicator = function () { return $($(_converse.rosterview.el).find(msgsIndicatorSelector)); }; selectMsgsIndicator = () => $(_converse.rosterview.el).find(msgsIndicatorSelector);
chatbox.save('scrolled', true); chatbox.save('scrolled', true);
@ -1591,7 +1591,7 @@
}; };
const selectUnreadMsgCount = function () { const selectUnreadMsgCount = function () {
const minimizedChatBoxView = _converse.minimized_chats.get(sender_jid); const minimizedChatBoxView = _converse.minimized_chats.get(sender_jid);
return $(minimizedChatBoxView.el).find('.message-count'); return minimizedChatBoxView.el.querySelector('.message-count');
}; };
const chatbox = _converse.chatboxes.get(sender_jid); const chatbox = _converse.chatboxes.get(sender_jid);
@ -1601,9 +1601,9 @@
const chatboxview = _converse.chatboxviews.get(sender_jid); const chatboxview = _converse.chatboxviews.get(sender_jid);
chatboxview.minimize(); chatboxview.minimize();
const $unreadMsgCount = selectUnreadMsgCount(); const unread_count = selectUnreadMsgCount();
expect(u.isVisible($unreadMsgCount[0])).toBeTruthy(); expect(u.isVisible(unread_count)).toBeTruthy();
expect($unreadMsgCount.html()).toBe('1'); expect(unread_count.innerHTML).toBe('1');
done(); done();
}); });
})); }));
@ -1625,7 +1625,7 @@
}; };
const selectUnreadMsgCount = function () { const selectUnreadMsgCount = function () {
const minimizedChatBoxView = _converse.minimized_chats.get(sender_jid); const minimizedChatBoxView = _converse.minimized_chats.get(sender_jid);
return $(minimizedChatBoxView.el).find('.message-count'); return minimizedChatBoxView.el.querySelector('.message-count');
}; };
const chatboxview = _converse.chatboxviews.get(sender_jid); const chatboxview = _converse.chatboxviews.get(sender_jid);
@ -1633,9 +1633,9 @@
_converse.chatboxes.onMessage(msgFactory()); _converse.chatboxes.onMessage(msgFactory());
const $unreadMsgCount = selectUnreadMsgCount(); const unread_count = selectUnreadMsgCount();
expect(u.isVisible($unreadMsgCount[0])).toBeTruthy(); expect(u.isVisible(unread_count)).toBeTruthy();
expect($unreadMsgCount.html()).toBe('1'); expect(unread_count.innerHTML).toBe('1');
done(); done();
}); });
})); }));

View File

@ -60,23 +60,25 @@
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
function (done, _converse) { function (done, _converse) {
let jid, room, chatroomview;
test_utils.createContacts(_converse, 'current'); test_utils.createContacts(_converse, 'current');
test_utils.waitUntil(function () { test_utils.waitUntil(() => _converse.rosterview.el.querySelectorAll('.roster-group .group-toggle').length, 300)
return $(_converse.rosterview.el).find('.roster-group .group-toggle').length; .then(() => test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy'))
}, 300).then(function () { .then(() => {
test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy').then(function () { jid = 'lounge@localhost';
var jid = 'lounge@localhost'; room = _converse.api.rooms.get(jid);
var room = _converse.api.rooms.get(jid);
expect(room instanceof Object).toBeTruthy(); expect(room instanceof Object).toBeTruthy();
var chatroomview = _converse.chatboxviews.get(jid); chatroomview = _converse.chatboxviews.get(jid);
expect(chatroomview.is_chatroom).toBeTruthy(); expect(chatroomview.is_chatroom).toBeTruthy();
expect(u.isVisible(chatroomview.el)).toBeTruthy(); expect(u.isVisible(chatroomview.el)).toBeTruthy();
chatroomview.close(); chatroomview.close();
// Test with mixed case // Test with mixed case
test_utils.openAndEnterChatRoom(_converse, 'Leisure', 'localhost', 'dummy').then(function () { return test_utils.openAndEnterChatRoom(_converse, 'Leisure', 'localhost', 'dummy');
}).then(() => {
jid = 'Leisure@localhost'; jid = 'Leisure@localhost';
room = _converse.api.rooms.get(jid); room = _converse.api.rooms.get(jid);
expect(room instanceof Object).toBeTruthy(); expect(room instanceof Object).toBeTruthy();
@ -102,8 +104,6 @@
expect(typeof room === 'undefined').toBeTruthy(); expect(typeof room === 'undefined').toBeTruthy();
done(); done();
}); });
});
});
})); }));
it("has a method 'open' which opens (optionally configures) and returns a wrapped chat box", it("has a method 'open' which opens (optionally configures) and returns a wrapped chat box",
@ -2680,7 +2680,8 @@
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
function (done, _converse) { function (done, _converse) {
test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy').then(function () { test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy')
.then(() => {
var sent_IQ, IQ_id; var sent_IQ, IQ_id;
var sendIQ = _converse.connection.sendIQ; var sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) { spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {