-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.test.js
111 lines (96 loc) · 3.3 KB
/
server.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// const express = require('express');
// const app = express();
//
const request = require('supertest')
const app = require('./server')
// const app = require('../../src/app')
const {
groceristar,
showcase
} = require('@groceristar/groceristar-fetch')
describe('Test the root path', () => {
test('It should response the GET method getStatus()', (done) => {
request(app).get('/status').then((response) => {
console.log(response.statusCode)
expect(response.statusCode).toBe(200)
done()
})
})
test('It should response the GET method getRoutes()', (done) => {
request(app).get('/hello').then((response) => {
console.log(response.statusCode)
expect(response.statusCode).toBe(200)
done()
})
})
/* @TODO START. REPLACE LATER WITH CONSTANTS FOR urls */
test('It should response the GET method getDepartmentsClean()', (done) => {
request(app).get('/gs/get-departments-clean').then((response) => {
console.log(response.statusCode)
expect(response.statusCode).toBe(200)
done()
})
})
test('It should response the GET method getGroceryById()', (done) => {
request(app).get('/gs/get-grocery-by-id/1').then((response) => {
console.log(response.statusCode)
expect(response.statusCode).toBe(200)
done()
})
})
test('It should response the GET method getFullGrocery()', (done) => {
request(app).get('/gs/get-full-grocery/Ultimate Grocery List').then((response) => {
expect(response.statusCode).toBe(200)
done()
})
})
test('It should response the GET method getGroceryCollection()', (done) => {
request(app).get('/sh/get-grocery-collection').then((response) => {
expect(response.statusCode).toBe(200)
done()
})
})
test('It should response the GET method getAllGrocery()', (done) => {
request(app).get('/gs/get-all-grocery').then((response) => {
expect(response.statusCode).toBe(200)
done()
})
})
test('It should response the GET method getGroceryDataFromId()', (done) => {
request(app).get('/gs/get-grocery-data-from-id/1').then((response) => {
expect(response.statusCode).toBe(200)
done()
})
})
test('It should response the GET method getFirstFiveRecipes()', (done) => {
request(app).get('/ck/get-first-five-recipes').then((response) => {
expect(response.statusCode).toBe(200)
done()
})
})
test('It should response the GET method getGroceriesWithDepIngKey()', (done) => {
request(app).get('/gs/get-groceries-with-dep-ing-key').then((response) => {
expect(response.statusCode).toBe(200)
done()
})
}, 10000)
})
/* END. REPLACE LATER WITH CONSTANTS FOR urls */
describe('Test /hello', () => {
it('Should return Hello!', async () => {
const response = await request(app).get('/hello')
expect(response.text).toBe('Hello')
})
// it('Response equal getGroceryShowcase()!', async () => {
// const response = await request(app).get('/ck/get-first-five-recipes')
// let result = JSON.parse(response.text)
// // console.log(result);
// expect(result).toEqual(showcase.getGroceryShowcase())
// })
test('Should respons the Get method getRoutes()', (done) => {
request(app).get('/hello').then((response) => {
expect(response.text).toBe('Hello')
done()
})
})
})