-
Notifications
You must be signed in to change notification settings - Fork 1
/
cents-input.test.js
46 lines (34 loc) · 1.15 KB
/
cents-input.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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const CentsInput = require('./cents-input');
const options = {
prefix: 'R$ ',
separator: ',',
};
const instance = new CentsInput(options);
test('adds a digit to the initial value', () => {
instance.addDigit(1)
let floatNumber = instance.getFloat();
let formatedNumber = instance.getFormatted();
expect(floatNumber).toEqual(0.01);
expect(formatedNumber).toEqual('R$ 0,01');
});
test('adds the number 5 after the number 1', () => {
instance.addDigit(5)
let floatNumber = instance.getFloat();
let formatedNumber = instance.getFormatted();
expect(floatNumber).toEqual(0.15);
expect(formatedNumber).toEqual('R$ 0,15');
});
test('remove the last digit from the end of the current value', () => {
instance.removeDigit();
let floatNumber = instance.getFloat();
let formatedNumber = instance.getFormatted();
expect(floatNumber).toEqual(0.01);
expect(formatedNumber).toEqual('R$ 0,01');
});
test('adds the number 2 after the number 1', () => {
instance.addDigit(2)
let floatNumber = instance.getFloat();
let formatedNumber = instance.getFormatted();
expect(floatNumber).toEqual(0.12);
expect(formatedNumber).toEqual('R$ 0,12');
});