-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.test.js
136 lines (123 loc) · 3.63 KB
/
app.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
const assert = require('assert');
const request = require("./modules/Requests")
let user = {
"email": "[email protected]",
"firstName": "Test",
"password": "123456",
"lastName": "User",
"college": "PCET",
"course": "BE",
"branch": "COMP",
"year": 2021,
"div": "B",
"rollNumber": 256,
"isStudent": true,
"age": 18,
"dob": 187459,
"gender": "M",
"bloodGroup": "B+",
"aadharNumber": 74984898498,
"contactNumber": 879879879,
"emergencyContact": 549848498,
"currentAddress": "NA",
"city": "NASKS",
"state": "MH",
"pincode": 415875,
"haCovid": false,
"startCovidDate": 184847548,
"endCovidDate": 14541587,
"isVaccinated": false,
"vaccineType": "N",
"dateOfDose1": null,
"dateOfDose2": null,
"isRegisteredoncowin": false,
"caDonateblood": false,
"caDonateplasma": false,
"isRecovered": null
}
let requestObject = {
"requestType": "testing",
"requestObject": {
"name": 123,
"lalal": 456
}
}
let volunteerObject = {
"volunteerType": "testing",
"volunteerObject": {
"name": 123,
"lalal": 456
}
}
let TOKEN = null
describe('Testing API', () => {
it("API is Up", (done) => {
request.checkHealth().then(res => {
let { status, message } = res.data
assert.equal(status, 200, "Status error")
assert.equal(message, "ok", "Incorrect message")
done()
}).catch(console.log)
})
it("User registration", (done) => {
user.email = `testuser-${Math.random() * 50}@gmial.com`
request.register(user).then(res => {
let { status, message, token } = res.data
assert.equal(status, 200, "Status error")
assert.equal(message, "User added successfully", "Incorrect message")
assert.notEqual(token, null, "Invalid Token")
done()
}).catch(console.log)
})
it("User Login", (done) => {
request.login(user.email, user.password).then(res => {
let { status, message, token } = res.data
assert.equal(status, 200, "Status error")
assert.equal(message, "User logged In successfully", "Incorrect message")
TOKEN = token
done()
}).catch(console.log)
})
it("Fetch User data", (done) => {
request.getData(TOKEN).then(res => {
let { status, userData } = res.data
assert.equal(status, 200, "Status error")
assert.notEqual(userData, {}, "Incorrect data")
done()
}).catch(console.log)
})
it("Add request", (done) => {
request.addRequest(TOKEN, requestObject).then(res => {
let { status, message, requestId } = res.data
assert.equal(status, 200, "Status error")
assert.equal(message, "Request added successfully", "Incorrect message")
assert.notEqual(requestId, undefined, "Incorrect data")
done()
}).catch(console.log)
})
it("Get user requests", (done) => {
request.getRequests(TOKEN).then(res => {
let { status, requests } = res.data
assert.equal(status, 200, "Status error")
assert.notEqual(requests, [], "Incorrect data")
done()
}).catch(console.log)
})
it("Add Volunteer", (done) => {
request.addVolunteer(TOKEN, volunteerObject).then(res => {
let { status, message, volunteerId } = res.data
assert.equal(status, 200, "Status error")
assert.equal(message, "Volunteer added successfully", "Incorrect message")
assert.notEqual(volunteerId, undefined, "Incorrect data")
done()
}).catch(console.log)
})
it("Get volunteers", (done) => {
request.getRequests(TOKEN).then(res => {
let { status, volunteers } = res.data
assert.equal(status, 200, "Status error")
assert.notEqual(volunteers, [], "Incorrect data")
done()
}).catch(console.log)
})
})