source: trip-planner-front/node_modules/hdr-histogram-js/dist/formatters.spec.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.7 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const formatters_1 = require("./formatters");
4describe("Integer formatter", () => {
5 it("should format integer as a string", () => {
6 // given
7 const formatter = formatters_1.integerFormatter(3);
8 // when
9 const result = formatter(123);
10 // then
11 expect(result).toBe("123");
12 });
13 it("should add padding on the left when input has a few digits", () => {
14 // given
15 const formatter = formatters_1.integerFormatter(5);
16 // when
17 const result = formatter(123);
18 // then
19 expect(result).toBe(" 123");
20 });
21});
22describe("Integer processor", () => {
23 it("should keep value unchanged when value small enough comapred to number of value digits", () => {
24 // given
25 const processor = formatters_1.keepSignificantDigits(3);
26 // when
27 const result = processor(421);
28 // then
29 expect(result).toBe(421);
30 });
31 it("should lower value when value has more digits than what is needed", () => {
32 // given
33 const processor = formatters_1.keepSignificantDigits(3);
34 // when
35 const result = processor(123456);
36 // then
37 expect(result).toBe(123000);
38 });
39});
40describe("Float formatter", () => {
41 it("should format float as a string", () => {
42 // given
43 const formatter = formatters_1.floatFormatter(5, 2);
44 // when
45 const result = formatter(12.34);
46 // then
47 expect(result).toBe("12.34");
48 });
49 it("should format float as a string with given number of fraction digits", () => {
50 // given
51 const formatter = formatters_1.floatFormatter(5, 2);
52 // when
53 const result = formatter(12.342);
54 // then
55 expect(result).toBe("12.34");
56 });
57 it("should format float as a string adding fraction digits", () => {
58 // given
59 const formatter = formatters_1.floatFormatter(5, 2);
60 // when
61 const result = formatter(12.3);
62 // then
63 expect(result).toBe("12.30");
64 });
65 it("should format the whole float input even with lots of digits", () => {
66 // given
67 const formatter = formatters_1.floatFormatter(5, 2);
68 // when
69 const result = formatter(12456789.34);
70 // then
71 expect(result).toBe("12456789.34");
72 });
73 it("should add padding on the left when not enough digits", () => {
74 // given
75 const formatter = formatters_1.floatFormatter(5, 2);
76 // when
77 const result = formatter(9.34);
78 // then
79 expect(result).toBe(" 9.34");
80 });
81});
82//# sourceMappingURL=formatters.spec.js.map
Note: See TracBrowser for help on using the repository browser.