From 4b98a637a56259cc580dff7576790c54cc73f96f Mon Sep 17 00:00:00 2001 From: Lucas Sanders Date: Tue, 21 Mar 2017 00:56:33 -0400 Subject: [PATCH] Update Ukrainian locale tests for immutability Also ensure that we always test both the 11:00 hour and the non-11:00 formatting variations, instead of simply testing whichever hour it happens to be when we run the test. --- src/test/locale/uk.js | 20 +++++++++++++++----- src/test/moment/duration.js | 2 +- src/test/moment/mutable.js | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/test/locale/uk.js b/src/test/locale/uk.js index b2eefc80e..7a53247e4 100644 --- a/src/test/locale/uk.js +++ b/src/test/locale/uk.js @@ -183,10 +183,15 @@ test('calendar next week', function (assert) { var i, m; for (i = 2; i < 7; i++) { m = moment().add({d: i}); - assert.equal(m.calendar(), m.format('[У] dddd [о' + (m.hours() === 11 ? 'б' : '') + '] LT'), 'Today + ' + i + ' days current time'); - m.hours(0).minutes(0).seconds(0).milliseconds(0); + if (m.hours() === 11) { + m = m.hours(10); + } + assert.equal(m.calendar(), m.format('[У] dddd [о] LT'), 'Today + ' + i + ' days current time'); + m = m.hours(11); + assert.equal(m.calendar(), m.format('[У] dddd [об] LT'), 'Today + ' + i + ' days 11:00 hour'); + m = m.hours(0).minutes(0).seconds(0).milliseconds(0); assert.equal(m.calendar(), m.format('[У] dddd [о] LT'), 'Today + ' + i + ' days beginning of day'); - m.hours(23).minutes(59).seconds(59).milliseconds(999); + m = m.hours(23).minutes(59).seconds(59).milliseconds(999); assert.equal(m.calendar(), m.format('[У] dddd [о] LT'), 'Today + ' + i + ' days end of day'); } }); @@ -210,10 +215,15 @@ test('calendar last week', function (assert) { for (i = 2; i < 7; i++) { m = moment().subtract({d: i}); + if (m.hours() === 11) { + m = m.hours(10); + } assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time'); - m.hours(0).minutes(0).seconds(0).milliseconds(0); + m = m.hours(11); + assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days 11:00 hour'); + m = m.hours(0).minutes(0).seconds(0).milliseconds(0); assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day'); - m.hours(23).minutes(59).seconds(59).milliseconds(999); + m = m.hours(23).minutes(59).seconds(59).milliseconds(999); assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day'); } }); diff --git a/src/test/moment/duration.js b/src/test/moment/duration.js index c13f34902..29f36160e 100644 --- a/src/test/moment/duration.js +++ b/src/test/moment/duration.js @@ -681,7 +681,7 @@ test('subtract', function (assert) { test('abs', function (assert) { var d = moment.duration({months: 2, weeks: 2, hours: 5}); assert.equal(+d.abs(), +d); - + d = moment.duration({months: -2, weeks: -2, hours: -5}); assert.equal(+d.abs(), -d); }); diff --git a/src/test/moment/mutable.js b/src/test/moment/mutable.js index ea4c8ffd3..7f8597e70 100644 --- a/src/test/moment/mutable.js +++ b/src/test/moment/mutable.js @@ -28,7 +28,7 @@ test('moment manipulation methods', function (assert) { test('duration manipulation methods', function (assert) { var d = moment.duration({months: 2, weeks: 2, days: 0, hours: 5}); - + assert.notEqual(d, moment.duration(d), 'constructor should return a new duration'); assert.notEqual(d, d.abs(), 'abs() should return a new duration'); assert.notEqual(d, d.add(1, 'days'), 'add() should return a new duration'); -- 2.47.2