]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Added tests for #2978
authorAfanasii Kurakin <afanasy@gmail.com>
Tue, 8 Mar 2016 03:37:11 +0000 (11:37 +0800)
committerIskren Chernev <iskren.chernev@gmail.com>
Sat, 16 Apr 2016 07:39:50 +0000 (00:39 -0700)
src/test/moment/duration.js

index 1312bf7beefbe54a12954e56dddbb04652df4525..e855f21cf6c0e1098d0c092ef7983a728f68ae8a 100644 (file)
@@ -548,6 +548,13 @@ test('as getters for small units', function (assert) {
     assert.equal(dm.asMinutes(),        13, 'asMinutes()');
 });
 
+test('minutes getter for floating point hours', function (assert) {
+    // Tests for issue #2978.
+    // For certain floating point hours, .minutes() getter produced incorrect values due to the rounding errors
+    assert.equal(moment.duration(2.3, 'h').minutes(), 18, 'minutes()');
+    assert.equal(moment.duration(4.1, 'h').minutes(), 6, 'minutes()');
+});
+
 test('isDuration', function (assert) {
     assert.ok(moment.isDuration(moment.duration(12345678)), 'correctly says true');
     assert.ok(!moment.isDuration(moment()), 'moment object is not a duration');
@@ -636,4 +643,3 @@ test('duration plugins', function (assert) {
     };
     durationObject.foo(5);
 });
-