File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,33 @@ describe('Cost computer', () => {
28
28
] ) ;
29
29
} ) ;
30
30
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
+
31
58
it ( 'Should take weekday in account' , ( ) => {
32
59
const result = computeCosts (
33
60
[
You can’t perform that action at this time.
0 commit comments