|
| 1 | +/* globals describe, it, beforeEach */ |
| 2 | +"use strict"; |
| 3 | + |
| 4 | +const should = require("should"); |
| 5 | +const SizeFormatHelpers = require("../lib/SizeFormatHelpers"); |
| 6 | + |
| 7 | +describe("SizeFormatHelpers", () => { |
| 8 | + describe("formatSize", () => { |
| 9 | + it("should handle zero size", () => { |
| 10 | + should(SizeFormatHelpers.formatSize(0)).be.eql("0 bytes"); |
| 11 | + }); |
| 12 | + |
| 13 | + it("should handle bytes", () => { |
| 14 | + should(SizeFormatHelpers.formatSize(1000)).be.eql("1000 bytes"); |
| 15 | + }); |
| 16 | + |
| 17 | + it("should handle integer kibibytes", () => { |
| 18 | + should(SizeFormatHelpers.formatSize(2048)).be.eql("2 KiB"); |
| 19 | + }); |
| 20 | + |
| 21 | + it("should handle float kibibytes", () => { |
| 22 | + should(SizeFormatHelpers.formatSize(2560)).be.eql("2.5 KiB"); |
| 23 | + }); |
| 24 | + |
| 25 | + it("should handle integer mebibytes", () => { |
| 26 | + should(SizeFormatHelpers.formatSize(10 * 1024 * 1024)).be.eql("10 MiB"); |
| 27 | + }); |
| 28 | + |
| 29 | + it("should handle float mebibytes", () => { |
| 30 | + should(SizeFormatHelpers.formatSize(12.5 * 1024 * 1024)).be.eql("12.5 MiB"); |
| 31 | + }); |
| 32 | + |
| 33 | + it("should handle integer gibibytes", () => { |
| 34 | + should(SizeFormatHelpers.formatSize(3 * 1024 * 1024 * 1024)).be.eql("3 GiB"); |
| 35 | + }); |
| 36 | + |
| 37 | + it("should handle float gibibytes", () => { |
| 38 | + should(SizeFormatHelpers.formatSize(1.2 * 1024 * 1024 * 1024)).be.eql("1.2 GiB"); |
| 39 | + }); |
| 40 | + }); |
| 41 | +}); |
0 commit comments