Test breaks when run in a different timezone

This commit is contained in:
JC Brand 2018-01-15 19:03:08 +01:00
parent e9bba77b36
commit 8c616f0edd

View File

@ -961,6 +961,7 @@
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
function (done, _converse) { function (done, _converse) {
test_utils.createContacts(_converse, 'current'); test_utils.createContacts(_converse, 'current');
test_utils.openControlBox(); test_utils.openControlBox();
test_utils.openContactsPanel(_converse); test_utils.openContactsPanel(_converse);
@ -1001,7 +1002,7 @@
msg = $msg({'id': 'aeb214', 'to': _converse.bare_jid}) msg = $msg({'id': 'aeb214', 'to': _converse.bare_jid})
.c('forwarded', {'xmlns': 'urn:xmpp:forward:0'}) .c('forwarded', {'xmlns': 'urn:xmpp:forward:0'})
.c('delay', {'xmlns': 'urn:xmpp:delay', 'stamp':'2017-12-31T23:08:25Z'}).up() .c('delay', {'xmlns': 'urn:xmpp:delay', 'stamp':'2017-12-31T22:08:25Z'}).up()
.c('message', { .c('message', {
'xmlns': 'jabber:client', 'xmlns': 'jabber:client',
'to': _converse.bare_jid, 'to': _converse.bare_jid,
@ -1049,7 +1050,7 @@
msg = $msg({'id': 'aeb218', 'to': _converse.bare_jid}) msg = $msg({'id': 'aeb218', 'to': _converse.bare_jid})
.c('forwarded', {'xmlns': 'urn:xmpp:forward:0'}) .c('forwarded', {'xmlns': 'urn:xmpp:forward:0'})
.c('delay', {'xmlns': 'urn:xmpp:delay', 'stamp':'2018-01-02T23:28:23Z'}).up() .c('delay', {'xmlns': 'urn:xmpp:delay', 'stamp':'2018-01-02T22:28:23Z'}).up()
.c('message', { .c('message', {
'xmlns': 'jabber:client', 'xmlns': 'jabber:client',
'to': _converse.bare_jid, 'to': _converse.bare_jid,
@ -1090,14 +1091,16 @@
var $time = $chat_content.find('time'); var $time = $chat_content.find('time');
expect($time.length).toEqual(4); expect($time.length).toEqual(4);
$time = $chat_content.find('time:first'); $time = $chat_content.find('time:first');
expect($time.data('isodate')).toEqual('2017-12-31T00:00:00+00:00'); expect($time.data('isodate')).toEqual(moment('2017-12-31T00:00:00').format());
expect($time.text()).toEqual('Sunday Dec 31st 2017')
expect($time[0].nextElementSibling.querySelector('.chat-msg-content').textContent).toBe('Older message'); expect($time[0].nextElementSibling.querySelector('.chat-msg-content').textContent).toBe('Older message');
var $el = $chat_content.find('.chat-message:first').find('.chat-msg-content') var $el = $chat_content.find('.chat-message:first').find('.chat-msg-content')
expect($el.text()).toEqual('Older message'); expect($el.text()).toEqual('Older message');
$time = $chat_content.find('time:eq(1)'); $time = $chat_content.find('time:eq(1)');
expect($time.data('isodate')).toEqual('2018-01-01T00:00:00+00:00'); expect($time.data('isodate')).toEqual(moment('2018-01-01T00:00:00').format());
expect($time.text()).toEqual("Monday Jan 1st 2018");
expect($time[0].nextElementSibling.querySelector('.chat-msg-content').textContent).toBe('Inbetween message'); expect($time[0].nextElementSibling.querySelector('.chat-msg-content').textContent).toBe('Inbetween message');
$el = $chat_content.find('.chat-message:eq(1)'); $el = $chat_content.find('.chat-message:eq(1)');
expect($el.find('.chat-msg-content').text()).toEqual('Inbetween message'); expect($el.find('.chat-msg-content').text()).toEqual('Inbetween message');
@ -1106,7 +1109,8 @@
expect($el.find('.chat-msg-content').text()).toEqual('another inbetween message'); expect($el.find('.chat-msg-content').text()).toEqual('another inbetween message');
$time = $chat_content.find('time:nth(2)'); $time = $chat_content.find('time:nth(2)');
expect($time.data('isodate')).toEqual('2018-01-02T00:00:00+00:00'); expect($time.data('isodate')).toEqual(moment('2018-01-02T00:00:00').format());
expect($time.text()).toEqual("Tuesday Jan 2nd 2018");
expect($time[0].nextElementSibling.querySelector('.chat-msg-content').textContent).toBe('An earlier message on the next day'); expect($time[0].nextElementSibling.querySelector('.chat-msg-content').textContent).toBe('An earlier message on the next day');
$el = $chat_content.find('.chat-message:eq(3)'); $el = $chat_content.find('.chat-message:eq(3)');
expect($el.find('.chat-msg-content').text()).toEqual('An earlier message on the next day'); expect($el.find('.chat-msg-content').text()).toEqual('An earlier message on the next day');