-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfetch_monthly_average_1.ts
62 lines (49 loc) · 1.55 KB
/
fetch_monthly_average_1.ts
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
import {Device} from "homey";
import moment from 'moment-timezone';
import Logger from '@balmli/homey-logger';
import {Currency, PricesFetchClient} from "../lib";
moment.tz.setDefault("Europe/Oslo");
class HomeyDevice {
storage: Map<string, any>;
constructor() {
this.storage = new Map<string, any>();
}
getStoreKeys = () => {
return Array.from(this.storage.keys());
}
setStoreValue = (key: string, value: any) => {
this.storage.set(key, value);
}
getStoreValue = (key: string) => {
return this.storage.get(key);
}
unsetStoreValue = (key: string) => {
this.storage.delete(key);
}
}
describe('Fetch monthly average', function () {
describe('Check monthly average', function () {
it('Check monthly average 1', function (done) {
const logger = new Logger({
logLevel: 2,
prefix: undefined,
});
const testDevice = new HomeyDevice();
const client = new PricesFetchClient({logger});
const localTime = moment();//.startOf('day');
// @ts-ignore
client.fetchMonthlyAverage(testDevice as Device, localTime, {
priceArea: 'Bergen',
currency: Currency.NOK
})
.then((avg) => {
//console.log(avg);
done();
})
.catch((err) => {
console.log('ERROR', err)
done();
});
});
});
});