-
Notifications
You must be signed in to change notification settings - Fork 17
/
server.test.js
32 lines (27 loc) · 892 Bytes
/
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
const app = require('./server') // Link to your server file
const supertest = require('supertest')
const request = supertest(app)
it('Call the /youtube endpoint', async done => {
const res = await request.get('/youtube')
expect(res.status).toBe(200)
expect(res.text).toBe('Hello, youtube indonesia!')
done()
})
it('Call the / endpoint', async done => {
const res = await request.get('/')
expect(res.status).toBe(200)
expect(res.text).toBe('This App is running properly!')
done()
})
it('Call the /pong endpoint', async done => {
const res = await request.get('/ping')
expect(res.status).toBe(200)
expect(res.text).toBe('Pong!')
done()
})
it('Call the /hello/:name endpoint', async done => {
const res = await request.get('/hello/Iqbal')
expect(res.status).toBe(200)
expect(res.body.message).toBe('Hello Iqbal')
done()
})