Mooeypoo has uploaded a new change for review. https://gerrit.wikimedia.org/r/321793
Change subject: Fix 'getTimestamp' default check in NotificationItem unit test ...................................................................... Fix 'getTimestamp' default check in NotificationItem unit test Initially this test checked whether when we ask for the default value of 'getTimestamp' we are getting a 'now' value. This is flawed because there could be (and is, apparently) a difference in time between instantiating the object and getting the result, which meant that the test failed. Instead, we remove this default test and bring it back specifically after the automatic tests - this time, we are just checking that the format of the default timestamp is the correct format that we expect. This will prevent us from guessing the 'now' time of the request and dealing with storing times, etc. Change-Id: Ic1c1e4ce8e4cd8afc337535d5b33ec2d2f63f514 --- M tests/qunit/model/test_mw.echo.dm.NotificationItem.js 1 file changed, 14 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo refs/changes/93/321793/1 diff --git a/tests/qunit/model/test_mw.echo.dm.NotificationItem.js b/tests/qunit/model/test_mw.echo.dm.NotificationItem.js index 10ac6c7..22464bf 100644 --- a/tests/qunit/model/test_mw.echo.dm.NotificationItem.js +++ b/tests/qunit/model/test_mw.echo.dm.NotificationItem.js @@ -30,7 +30,7 @@ QUnit.module( 'ext.echo.dm - mw.echo.dm.NotificationItem' ); QUnit.test( 'Constructing items', function ( assert ) { - var i, j, itemModel, checkMethods, + var i, j, itemModel, checkMethods, defaultTimestamp, defaultValues = { getId: undefined, getContentHeader: '', @@ -41,7 +41,6 @@ isSeen: false, isForeign: false, isBundled: false, - getTimestamp: moment.utc().format( 'YYYY-MM-DD[T]HH:mm:ss[Z]' ), getPrimaryUrl: undefined, getIconURL: undefined, getIconType: undefined, @@ -106,6 +105,19 @@ tests[ i ].msg + ' (' + checkMethods[ j ] + ')' ); } + + // Specifically check whether our fallback timestamp works + // We can't give the system the regular "check whether we are + // getting 'now'" value because there may be a difference + // between the 'now' it is instantiating with and the + // 'now' that it is checking. Instead, we will verify that the + // time we are recieving as the fallback value is in the correct format + itemModel = new mw.echo.dm.NotificationItem( 0 ); + defaultTimestamp = itemModel.getTimestamp(); + assert.ok( + moment( defaultTimestamp, 'YYYY-MM-DD[T]HH:mm:ss[Z]' ) + .format( 'YYYY-MM-DD[T]HH:mm:ss[Z]' ) === defaultTimestamp + ); } } ); -- To view, visit https://gerrit.wikimedia.org/r/321793 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic1c1e4ce8e4cd8afc337535d5b33ec2d2f63f514 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Echo Gerrit-Branch: master Gerrit-Owner: Mooeypoo <mor...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits