1 | import jsonServer from 'json-server'; |
||
2 | import { assert } from 'chai'; |
||
3 | import axios from 'axios'; |
||
4 | import bodyParser from 'body-parser'; |
||
5 | import curl from '../entry'; |
||
6 | |||
7 | const port = 12_653; |
||
0 ignored issues
–
show
|
|||
8 | const users = [ { |
||
9 | 'id' : 1, |
||
10 | 'name' : 'Leigh', |
||
11 | 'email' : '[email protected]' |
||
12 | }, { |
||
13 | 'id' : 2, |
||
14 | 'name' : 'Ancell', |
||
15 | 'email' : '[email protected]' |
||
16 | } ]; |
||
17 | |||
18 | const server = jsonServer.create(); |
||
19 | const router = jsonServer.router({ users }); |
||
20 | |||
21 | suite('Default configuration'); |
||
22 | |||
23 | before(async function () { |
||
24 | server.use(bodyParser.json()); |
||
25 | server.use(curl); |
||
26 | server.use(router); |
||
27 | await new Promise(res => { |
||
28 | server.listen(port, res); |
||
29 | }); |
||
30 | }); |
||
31 | |||
32 | test('Get all users', async function () { |
||
33 | assert.deepEqual( |
||
34 | await axios({ |
||
35 | method : 'GET', |
||
36 | url : `http://localhost:${port}/users?limit=5` |
||
37 | }).then(r => r.data), |
||
38 | users |
||
39 | ); |
||
40 | }); |
||
41 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.