Skip to content

Commit

Permalink
Added tests for moment#2978
Browse files Browse the repository at this point in the history
  • Loading branch information
afanasy committed Mar 8, 2016
1 parent 6a0ad2b commit f56ebcb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/test/moment/duration.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,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');
Expand Down Expand Up @@ -628,4 +635,3 @@ test('duration plugins', function (assert) {
};
durationObject.foo(5);
});

0 comments on commit f56ebcb

Please sign in to comment.