]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Update Ukrainian locale tests for immutability
authorLucas Sanders <butterflyhug@google.com>
Tue, 21 Mar 2017 04:56:33 +0000 (00:56 -0400)
committerLucas Sanders <butterflyhug@google.com>
Wed, 22 Mar 2017 11:00:21 +0000 (07:00 -0400)
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
src/test/moment/duration.js
src/test/moment/mutable.js

index b2eefc80e405b3ad1f8a81698028619dd035b459..7a53247e4858d2acdd4e5afa4497d0c4621190b5 100644 (file)
@@ -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');
     }
 });
index c13f34902474b7429edad4e20fbcd5224062c9a2..29f36160e568393ecf1cc171ed9481dbb32be38e 100644 (file)
@@ -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);
 });
index ea4c8ffd3b3d9cb53521273e2506ad644400109a..7f8597e7090441048af303d20c1b476c833b523e 100644 (file)
@@ -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');