const assert = require('assert');
const nock = require('nock');
require('isomorphic-fetch');
function getData() {
return fetch('https://jsonplaceholder.typicode.com/users')
.then(response => response.json());
}
describe('getData', () => {
it('should fetch data', () => {
const request = nock('https://jsonplaceholder.typicode.com')
.get('/users')
.reply(200, [{username: 'joe'}]);
getData()
.then(response => {
assert.deepEqual(response, [{username: 'joe'}]);
assert.ok(request.isDone());
});
});
})