mnb-exchange-rate
Version:
[Docs - mnb.hu](https://www.mnb.hu/sajtoszoba/sajtokozlemenyek/2015-evi-sajtokozlemenyek/tajekoztatas-az-arfolyam-webservice-mukodeserol)
68 lines • 2.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const client_1 = require("./client");
const util_1 = require("./util");
function expectCurrenciesCurrList(res) {
expect(res.Currencies).toBeDefined();
expect(res.Currencies).toBeDefined();
expect(res.Currencies.length).toBeGreaterThan(0);
res.Currencies.forEach((c) => expect(c.length).toEqual(3));
}
describe('Client', () => {
const now = new Date();
const nowDate = (0, util_1.getDatePart)(now);
const nowDate_1 = (0, util_1.getDatePart)((0, util_1.subDateDays)(now, 1));
it('should be defined', async () => {
const client = await (0, client_1.getClient)();
expect(client).toBeDefined();
}, 10000);
it('should return info', async () => {
const client = await (0, client_1.getClient)();
const res = await client.GetInfo();
expect(res).toBeDefined();
expect(res.FirstDate).toMatch(/\d{4}-\d{2}-\d{2}/);
expect(res.LastDate).toMatch(/\d{4}-\d{2}-\d{2}/);
expectCurrenciesCurrList(res);
}, 20000);
it('should return currencies', async () => {
const client = await (0, client_1.getClient)();
const res = await client.GetCurrencies();
expect(res).toBeDefined();
expectCurrenciesCurrList(res);
}, 20000);
it('should return currency units', async () => {
const client = await (0, client_1.getClient)();
const currencies = ['EUR', 'HUF'];
const res = await client.GetCurrencyUnits({ currencies });
currencies.forEach(c => {
expect(res[c]).toBeDefined();
});
}, 20000);
it('should return stored interval', async () => {
const client = await (0, client_1.getClient)();
const res = await client.GetDateInterval();
expect(res).toBeDefined();
expect(res.FirstDate).toBeDefined();
expect(res.LastDate).toBeDefined();
}, 20000);
it('should return current rates', async () => {
const client = await (0, client_1.getClient)();
const res = await client.GetCurrentExchangeRates();
expect(res).toBeDefined();
}, 20000);
it('should return exchange rates', async () => {
const client = await (0, client_1.getClient)();
const res = await client.GetExchangeRates({
startDate: nowDate_1,
endDate: nowDate,
currencies: ['EUR', 'USD'],
});
expect(res).toBeDefined();
Object.values(res).forEach(d => {
Object.values(d).forEach(n => {
expect(n).toBeGreaterThan(0);
});
});
}, 20000);
});
//# sourceMappingURL=client.test.js.map