mirror of
https://github.com/element-hq/synapse
synced 2024-08-19 05:40:58 +00:00
Add extra checks to duration filter.
This commit is contained in:
parent
5ebd004a10
commit
d4f6d65e1d
2 changed files with 8 additions and 0 deletions
|
@ -26,6 +26,9 @@ angular.module('matrixWebClient')
|
||||||
var h = parseInt(t / (60 * 60)) % 24;
|
var h = parseInt(t / (60 * 60)) % 24;
|
||||||
var d = parseInt(t / (60 * 60 * 24));
|
var d = parseInt(t / (60 * 60 * 24));
|
||||||
if (t < 60) {
|
if (t < 60) {
|
||||||
|
if (t < 0) {
|
||||||
|
return "0s";
|
||||||
|
}
|
||||||
return s + "s";
|
return s + "s";
|
||||||
}
|
}
|
||||||
if (t < 60 * 60) {
|
if (t < 60 * 60) {
|
||||||
|
|
|
@ -285,6 +285,11 @@ describe('duration filter', function() {
|
||||||
var output = durationFilter(1000*60*60*2 + 1000*60*35);
|
var output = durationFilter(1000*60*60*2 + 1000*60*35);
|
||||||
expect(output).toEqual("2h");
|
expect(output).toEqual("2h");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should represent -ve numbers as '0s'", function() {
|
||||||
|
var output = durationFilter(-2000);
|
||||||
|
expect(output).toEqual("0s");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('orderMembersList filter', function() {
|
describe('orderMembersList filter', function() {
|
||||||
|
|
Loading…
Reference in a new issue