I have a function that makes an API
request and receives data in json
format.
async function getDataAboutWeather(url) {
return await new Promise(resolve => {
request(url, (err, res, body) => {
if (err) {
throw new Error(err);
};
const info = JSON.parse(body);
resolve(info);
});
});
};
I want to write a test for this function.
describe('getDataAboutWeather function', () => {
it('The request should success', () => {
const link = 'http://ip.jsontest.com';
expect(getDataAboutWeather(link)).to.eql({});
});
});
How to verify that my function works as it should?
Since at the moment I get an error.
AssertionError: expected {} to deeply equal {}
Aucun commentaire:
Enregistrer un commentaire