From 80339aef934e6d187b3cfff2d2c38fb52fcae7c9 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 2 Jan 2015 15:29:51 +1300 Subject: Unit test framework for web client-side code - Also make formatSize nicer and test it. Now there's no excuse! ;) --- web/src/js/tests/utils.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 web/src/js/tests/utils.js (limited to 'web/src/js/tests') diff --git a/web/src/js/tests/utils.js b/web/src/js/tests/utils.js new file mode 100644 index 00000000..dfbb9ba6 --- /dev/null +++ b/web/src/js/tests/utils.js @@ -0,0 +1,15 @@ +jest.dontMock("jquery"); +jest.dontMock("../utils"); + +describe("utils", function () { + var utils = require("../utils"); + it("formatSize", function(){ + expect(utils.formatSize(1024)).toEqual("1kb"); + expect(utils.formatSize(0)).toEqual("0"); + expect(utils.formatSize(10)).toEqual("10b"); + expect(utils.formatSize(1025)).toEqual("1.0kb"); + expect(utils.formatSize(1024*1024)).toEqual("1mb"); + expect(utils.formatSize(1024*1024+1)).toEqual("1.0mb"); + }); +}); + -- cgit v1.2.3