-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
23 lines (19 loc) · 1.07 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const Decimal = require('./index.js');
test('add', async () => {
expect((new Decimal(10.25).add(new Decimal(10.25))).toNumber()).toEqual(10.25 + 10.25)
expect((new Decimal(10.25).add(new Decimal(10.205))).toNumber()).toEqual(10.25 + 10.205)
})
test('mul', async () => {
expect((new Decimal(10.25).mul(new Decimal(10.25))).toNumber()).toEqual(10.25 * 10.25);
expect((new Decimal(10.25).mul(new Decimal(104.254))).toNumber()).toEqual(10.25 * 104.254);
})
test('div', async () => {
expect((new Decimal(10.25).div(new Decimal(10.25))).toNumber()).toEqual(10.25 / 10.25);
expect((new Decimal(10.25).div(new Decimal(104.254))).toNumber()).toEqual(10.25 / 104.254);
expect((new Decimal(104.254).div(new Decimal(10.25))).toNumber()).toEqual(104.254 / 10.25);
})
test('sub', async () => {
expect((new Decimal(10.25).sub(new Decimal(10.25))).toNumber()).toEqual(10.25 - 10.25);
expect((new Decimal(10.25).sub(new Decimal(3.14159))).toNumber()).toEqual(10.25 - 3.14159);
expect((new Decimal(3.14159).sub(new Decimal(10.25))).toNumber()).toEqual(3.14159 - 10.25);
})