mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Add duration filter unit tests.
This commit is contained in:
parent
6aba43f6cc
commit
69c396825b
@ -29,10 +29,10 @@ angular.module('matrixWebClient')
|
||||
return s + "s";
|
||||
}
|
||||
if (t < 60 * 60) {
|
||||
return m + "m "; // + s + "s";
|
||||
return m + "m"; // + s + "s";
|
||||
}
|
||||
if (t < 24 * 60 * 60) {
|
||||
return h + "h "; // + m + "m";
|
||||
return h + "h"; // + m + "m";
|
||||
}
|
||||
return d + "d "; // + h + "h";
|
||||
};
|
||||
@ -76,17 +76,6 @@ angular.module('matrixWebClient')
|
||||
return filtered;
|
||||
};
|
||||
})
|
||||
.filter('stateEventsFilter', function($sce) {
|
||||
return function(events) {
|
||||
var filtered = {};
|
||||
angular.forEach(events, function(value, key) {
|
||||
if (value && typeof(value.state_key) === "string") {
|
||||
filtered[key] = value;
|
||||
}
|
||||
});
|
||||
return filtered;
|
||||
};
|
||||
})
|
||||
.filter('unsafe', ['$sce', function($sce) {
|
||||
return function(text) {
|
||||
return $sce.trustAsHtml(text);
|
||||
|
50
syweb/webclient/test/unit/filters.spec.js
Normal file
50
syweb/webclient/test/unit/filters.spec.js
Normal file
@ -0,0 +1,50 @@
|
||||
describe('durationFilter', function() {
|
||||
var filter, durationFilter;
|
||||
|
||||
beforeEach(module('matrixWebClient'));
|
||||
beforeEach(module('matrixFilter'));
|
||||
beforeEach(inject(function($filter) {
|
||||
filter = $filter;
|
||||
durationFilter = filter("duration");
|
||||
}));
|
||||
|
||||
it("should represent 15000 ms as '15s'", function() {
|
||||
var output = durationFilter(15000);
|
||||
expect(output).toEqual("15s");
|
||||
});
|
||||
|
||||
it("should represent 60000 ms as '1m'", function() {
|
||||
var output = durationFilter(60000);
|
||||
expect(output).toEqual("1m");
|
||||
});
|
||||
|
||||
it("should represent 65000 ms as '1m'", function() {
|
||||
var output = durationFilter(65000);
|
||||
expect(output).toEqual("1m");
|
||||
});
|
||||
|
||||
it("should represent 10 ms as '0s'", function() {
|
||||
var output = durationFilter(10);
|
||||
expect(output).toEqual("0s");
|
||||
});
|
||||
|
||||
it("should represent 4m as '4m'", function() {
|
||||
var output = durationFilter(1000*60*4);
|
||||
expect(output).toEqual("4m");
|
||||
});
|
||||
|
||||
it("should represent 4m30s as '4m'", function() {
|
||||
var output = durationFilter(1000*60*4 + 1000*30);
|
||||
expect(output).toEqual("4m");
|
||||
});
|
||||
|
||||
it("should represent 2h as '2h'", function() {
|
||||
var output = durationFilter(1000*60*60*2);
|
||||
expect(output).toEqual("2h");
|
||||
});
|
||||
|
||||
it("should represent 2h35m as '2h'", function() {
|
||||
var output = durationFilter(1000*60*60*2 + 1000*60*35);
|
||||
expect(output).toEqual("2h");
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user