Debian Codegraph @

addons/point_of_sale/static/tests/unit/tools/numbers.test.js

raw
1 import { expect, test } from "@odoo/hoot";
2 import { EQ, AbstractNumbers } from "@point_of_sale/app/utils/numbers";
3
4 class CustomNumbers extends AbstractNumbers {
5 constructor() {
6 super({});
7 }
8 get precision() {
9 return 0.05;
10 }
11 get method() {
12 return "UP";
13 }
14 }
15
16 const numbers = new CustomNumbers();
17
18 test("inputs are rounded before comparison", () => {
19 expect(numbers.comp(1.24, 1.21)).toBe(EQ);
20 expect(numbers.isZero(1.24 - 1.21)).toBe(false);
21 });
22
23 test("rounding", () => {
24 expect(numbers.round(1.28)).toBe(1.3);
25 expect(numbers.round(-1.28)).toBe(-1.3);
26 expect(numbers.asymmetricRound(1.28)).toBe(1.3);
27 expect(numbers.asymmetricRound(-1.28)).toBe(-1.25);
28 });