-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscripts.test.js
More file actions
31 lines (23 loc) · 904 Bytes
/
scripts.test.js
File metadata and controls
31 lines (23 loc) · 904 Bytes
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
const { getRequest, postRequest, putRequest, deleteRequest } = require('./scripts');
const testUrl1 = 'http://localhost:3000/api';
const testUrl2 = 'http://localhost:3000/api/1';
const getMethod = 'GET';
const postMethod = 'POST';
const putMethod = 'PUT';
const deleteMethod = 'DELETE';
test('Get request to ' + testUrl1 +' ... ', async () => {
const data = await getRequest(testUrl1);
expect(data.method).toBe(getMethod);
});
test('Post request to ' + testUrl1 +' ... ', async () => {
const data = await postRequest(testUrl1);
expect(data.method).toBe(postMethod);
});
test('Put request to ' + testUrl2 +' ... ', async () => {
const data = await putRequest(testUrl2);
expect(data.method).toBe(putMethod);
});
test('Delete request to ' + testUrl2 +' ... ', async () => {
const data = await deleteRequest(testUrl2);
expect(data.method).toBe(deleteMethod);
});