-
Notifications
You must be signed in to change notification settings - Fork 4
/
demo.test.js
78 lines (63 loc) · 2.25 KB
/
demo.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
require('dotenv').config()
const { expect } = require("expect")
const supertest = require('supertest')
const {app} = require('./server/test_server.js')
async function logAndToken(){
const response = await supertest(app).post("/api/consumer/login/")
.send({
email: "[email protected]",
password: "abCD12#$"
})
.set('Accept', 'application/json')
.set('Content-Type', 'application/json')
return response._body.data
}
test('demo testing for sum', () => {
expect(1 + 2).toBe(3)
})
test('testing get all services', async () => {
const response = await supertest(app).get("/api/customer/viewServices")
expect(response).not.toBe(null)
return
})
test('testing login user', async () => {
const response = await supertest(app).post("/api/consumer/login/")
.send({
email: "[email protected]",
password: "abCD12#$"
})
.set('Accept', 'application/json')
.set('Content-Type', 'application/json')
expect(response._body.data).not.toBe(null)
})
test('getting profile data', async () => {
const tokn = await logAndToken()
const response = await supertest(app).get("/api/consumer/profile")
.set('Accept', 'application/json')
.set('Content-Type', 'application/json')
.set("Authorization", `Bearer ${tokn}`)
// console.log(response)
expect(response._body.data).not.toBe(null)
})
test('getting list of broadcast', async () => {
const tkn = await logAndToken();
const response = await supertest(app).get("/api/consumer/viewbroadcast")
.set('Accept', 'application/json')
.set('Content-Type', 'application/json')
.set("Authorization", `Bearer ${tkn}`)
console.log(response._body)
expect(response._body.data).not.toBe(null)
})
test('fetching seller details for customer', async () => {
const tkn = await logAndToken();
const response = await supertest(app).post("/api/consumer/sellerprofileview")
.send({
pointer: "seller-id"
})
.set('Accept', 'application/json')
.set('Content-Type', 'application/json')
.set("Authorization", `Bearer ${tkn}`)
// console.log(response._body)
expect(response._body.data).toBe(undefined)
})
// Finalise