-
Notifications
You must be signed in to change notification settings - Fork 2
/
gateio.test.js
97 lines (78 loc) · 2.72 KB
/
gateio.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const extract_gateio_pair = require("./extract_gateio_pair");
describe('extract_gateio_pair', () => {
it('should return the expected output when valid JSON input is provided for a small amount', () => {
const json = {
result: {
price: '0.12345678'
}
};
const expectedOutput = {
pair: 'waxpeth',
value: 12345678
};
const result = extract_gateio_pair(json);
expect(result).toEqual(expectedOutput);
});
// Tests that valid JSON input with a non-zero price returns the expected output
it('should return the expected output when valid JSON input with a >0 price is provided', () => {
const json = {
result: {
price: '1.23456789'
}
};
const expectedOutput = {
pair: 'waxpeth',
value: 123456789
};
const result = extract_gateio_pair(json);
expect(result).toEqual(expectedOutput);
});
// Tests that valid JSON input with a zero price returns the expected output
it('should return the expected output when valid JSON input with a zero price is provided', () => {
const json = {
result: {
price: '0'
}
};
const expectedOutput = {
pair: 'waxpeth',
value: 0
};
const result = extract_gateio_pair(json);
expect(result).toEqual(expectedOutput);
});
// Tests that valid JSON input with a large price returns the expected output
it('should return the expected output when valid JSON input with a large price is provided', () => {
const json = {
result: {
price: '123456789.12345678'
}
};
const expectedOutput = {
pair: 'waxpeth',
value: 12345678912345678
};
const result = extract_gateio_pair(json);
expect(result).toEqual(expectedOutput);
});
// Tests that valid JSON input with a small price returns the expected output
it('should return the expected output when valid JSON input with a smallest price is provided', () => {
const json = {
result: {
price: '0.00000001'
}
};
const expectedOutput = {
pair: 'waxpeth',
value: 1
};
const result = extract_gateio_pair(json);
expect(result).toEqual(expectedOutput);
});
// Tests that invalid JSON input returns null
it('should return null when invalid JSON input is provided', () => {
const json = null;
const result = extract_gateio_pair(json);
expect(result).toBeNull();
});
});