summary refs log tree commit diff
path: root/syweb/webclient/test
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-11-05 17:49:03 +0000
committerKegan Dougal <kegan@matrix.org>2014-11-05 17:49:03 +0000
commit69c396825b28074346e3cfe3f239b5b1f2c143df (patch)
tree06390e22c6b640f88cbefa709722e46eb67e2282 /syweb/webclient/test
parentAdd a few eventHandlerService tests. (diff)
downloadsynapse-69c396825b28074346e3cfe3f239b5b1f2c143df.tar.xz
Add duration filter unit tests.
Diffstat (limited to 'syweb/webclient/test')
-rw-r--r--syweb/webclient/test/unit/filters.spec.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/syweb/webclient/test/unit/filters.spec.js b/syweb/webclient/test/unit/filters.spec.js
new file mode 100644
index 0000000000..3dc735b2c8
--- /dev/null
+++ b/syweb/webclient/test/unit/filters.spec.js
@@ -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");
+    });
+});
\ No newline at end of file