Skip to content

Commit 03372f5

Browse files
committed
Add new unit test
1 parent 8fec259 commit 03372f5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/cost.test.ts

+27
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,33 @@ describe('Cost computer', () => {
2828
]);
2929
});
3030

31+
it('Should not bug as described by #69', () => {
32+
const result = computeCosts(
33+
[
34+
{ start: '2023-06-01T00:00:00+01:00', state: 1000 * 100, sum: 0 }, // 100 kWh
35+
{ start: '2024-06-01T00:00:00+01:00', state: 1000 * 100, sum: 0 }, // 100 kWh
36+
],
37+
[
38+
{ price: 0.2516, start_date: '2024-02-01' },
39+
{ price: 0.2276, start_date: '2023-08-01', end_date: '2024-01-31' },
40+
{ price: 0.2062, start_date: '2023-02-01', end_date: '2023-07-31' },
41+
],
42+
);
43+
44+
expect(result).toEqual([
45+
{
46+
start: '2023-06-01T00:00:00+01:00',
47+
state: 20.62, // = 100 kWh * 0.2062
48+
sum: 20.62,
49+
},
50+
{
51+
start: '2024-06-01T00:00:00+01:00',
52+
state: 25.16, // = 100 kWh * 0.2516
53+
sum: 20.62 + 25.16,
54+
},
55+
]);
56+
});
57+
3158
it('Should take weekday in account', () => {
3259
const result = computeCosts(
3360
[

0 commit comments

Comments
 (0)