Slide 30
Slide 30 text
[...]
import fetchMock from 'fetch-mock';
[...]
test.afterEach(() => {
fetchMock.restore();
});
[...]
test.serial('should make an ajax request', t => {
fetchMock.mock('https://api.github.com/users/maur8ino/repos', 'GET', [
{ "id": 35957173, "name": "angular-post-message" },
{ "id": 37024234, "name": "react-bem-mixin" }
]);
return github.getUserReposList('maur8ino').then(response => {
t.deepEqual(response, [
{ id: 35957173, name: 'angular-post-message' },
{ id: 37024234, name: 'react-bem-mixin' }
]);
});
});
test/github-test.js