Add tests for interval describe

This commit is contained in:
Rashid Khan 2014-06-16 15:35:18 -07:00
parent ef17b9041f
commit 483e9c8ff9
3 changed files with 24 additions and 5 deletions

View file

@ -103,12 +103,12 @@ define(function (require) {
var seconds = parseInt(totalMs / 1000) % 60;
var ms = totalMs % 1000;
return (weeks ? weeks + 'w ' : '') +
return ((weeks ? weeks + 'w ' : '') +
(days ? days + 'd ' : '') +
(hours ? hours + 'h ' : '') +
(minutes ? (minutes < 10 ? '0' + minutes : minutes) + 'm ' : '') +
(seconds ? (seconds < 10 ? '0' + seconds : seconds) + 's ' : '') +
(ms ? ms + 'ms' : '');
(minutes ? minutes + 'm ' : '') +
(seconds ? seconds + 's ' : '') +
(ms ? ms + 'ms' : '')).trim();
};
var toMs = function (expr) {

View file

@ -31,7 +31,7 @@
exports: 'sinon'
}
},
waitSeconds: 60,
waitSeconds: 6000,
// mark all requested files with instrument query param
urlArgs: COVERAGE ? 'instrument=true' : void 0
});

View file

@ -19,6 +19,25 @@ define(function (require) {
});
});
describe('description', function () {
it('returns a readable description for an interval', function () {
expect(interval.describe('1ms')).to.be('1ms');
expect(interval.describe('1s')).to.be('1s');
expect(interval.describe('1m')).to.be('1m');
expect(interval.describe('1h')).to.be('1h');
expect(interval.describe('1d')).to.be('1d');
expect(interval.describe('1w')).to.be('1w');
expect(interval.describe('2w')).to.be('2w');
expect(interval.describe('86400000ms')).to.be('1d');
expect(interval.describe('86400001ms')).to.be('1d 1ms');
expect(interval.describe('90000000ms')).to.be('1d 1h');
expect(interval.describe('90060000ms')).to.be('1d 1h 1m');
expect(interval.describe('90061000ms')).to.be('1d 1h 1m 1s');
expect(interval.describe('90061300ms')).to.be('1d 1h 1m 1s 300ms');
});
});
describe('rounding', function () {
var mmnt, date, string, now, clock, then;