1const axios = require('axios');
2const Users = require('./users');
3
4jest.mock('axios');
5
6test('should fetch users', () => {
7
8 const users = [{
9 "id": 1,
10 "first_name": "Robert",
11 "last_name": "Schwartz",
12 "email": "rob23@gmail.com"
13 }, {
14 "id": 2,
15 "first_name": "Lucy",
16 "last_name": "Ballmer",
17 "email": "lucyb56@gmail.com"
18 }];
19
20 const resp = { data : users };
21
22 axios.get.mockImplementation(() => Promise.resolve(resp));
23
24 Users.all().then(resp => expect(resp.data).toEqual(users));
25});
26