-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsearch.test.js
52 lines (49 loc) · 1.49 KB
/
search.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const request = require('supertest');
const app = require('./search'); // Import your app or server
const httpMocks = require('node-mocks-http');
const fs = require('fs');
/* describe('Get /package/{id}', () => {
it('search a file with an working id', async () => {
const req = httpMocks.createRequest({
method: 'GET',
url: `/package/underscore-1.13.6`,
params: {
id: "underscore-1.13.6",
},
});
const res = httpMocks.createResponse();
await app(req, res);
// now you can make assertions about the response
expect(res.statusCode).toBe(200);
});
}); */
/* describe('Get /package/byName/{name}', () => {
it('search a file by Name', async () => {
const req = httpMocks.createRequest({
method: 'GET',
url: `/package/byName/underscore`,
params: {
name: "underscore",
},
});
const res = httpMocks.createResponse();
await app(req, res);
// now you can make assertions about the response
expect(res.statusCode).toBe(200);
});
}); */
describe('Get /package/RegEx', () => {
it('search a file with RegEx', async () => {
const req = httpMocks.createRequest({
method: 'POST',
url: `/package/byRegEx`,
body: {
regEx: "underscore",
},
});
const res = httpMocks.createResponse();
await app(req, res);
// now you can make assertions about the response
expect(res.statusCode).toBe(200);
});
});