-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
196 lines (177 loc) · 6.32 KB
/
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
const axios = require('axios');
const funcs = require('./fn');
test('Update a Partner', async() => {
body ={
"firstName": "Bishoy",
"lastName": "Wahib",
"age": 23,
"email": "[email protected]",
"password": "123456789",
"partner": true
}
expect.assertions(1)
const partner = await axios.post("http://localhost:3000/api/users",body)
const updatedPartner = await axios.put(`http://localhost:3000/api/users/${user.data.data._id}`,{"password": "bishoy2019"})
await axios.delete(`http://localhost:3000/api/users/${user.data.data._id}`)
expect(updatedPartner.status).toEqual(200)
});
test('Update a task', async () => {
body ={
"name": "taskName",
"description": "taskDescription",
"skillsRequired": ["Heraldry"],
"currentState": "Created",
"reviewed": true
}
expect.assertions(1)
const task = await axios.post("http://localhost:3000/api/tasks",body)
const updatedTask = await axios.put("http://localhost:3000/api/tasks/${task.data.data._id}",{"reviewed": false})
await axios.delete("http://localhost:3000/api/tasks/${task.data.data._id}")
expect(updatedTask.status).toEqual(200)
});
test('Update a user', async () => {
body ={
"firstName": "John",
"lastName": "Doe",
"age": 12,
"email": "[email protected]",
"password": "12345"
}
expect.assertions(1)
const user = await axios.post("http://localhost:3000/api/users",body)
const updatedUser = await axios.put("http://localhost:3000/api/users/${user.data.data._id}",{"age": 16})
await axios.delete("http://localhost:3000/api/users/${user.data.data._id}")
expect(updatedUser.status).toEqual(200)
});
test('Update a masterclass', async () => {
body ={
"name": "masterclassName",
"description": "masterclassDescription",
}
expect.assertions(1)
const masterclass = await axios.post("http://localhost:3000/api/masterclasses",body)
const updatedMasterclass = await axios.put("http://localhost:3000/api/masterclasses/${masterclass.data.data._id}",{"name": "masterclassName1"})
await axios.delete("http://localhost:3000/api/masterclasses/${masterclass.data.data._id}")
expect(updatedMasterclass.status).toEqual(200)
});
test('Create a user', async () => {
body ={
"firstName": "John",
"lastName": "Doe",
"age": 12,
"email": "[email protected]",
"password": "12345"
}
expect.assertions(1)
const user = await axios.post("http://localhost:3000/api/users",body)
expect(user.status).toEqual(200)
});
test(`Getting all tasks`, async () => {
expect.assertions(1)
const task = await funcs.getTask()
expect(task.status).toEqual(200)
});
test(`Getting all masterclasses`, async () => {
expect.assertions(1)
const masterclass = await funcs.getMasterclass()
expect(masterclass.status).toEqual(200)
});
test('Create a masterclass', async () => {
body ={
"name": "masterclassName",
"description": "masterclassDescription",
}
expect.assertions(1)
const masterclass = await axios.post("http://localhost:3000/api/masterclasses",body)
expect(masterclass.status).toEqual(200)
});
test('Create a task', async () => {
body ={
"name": "taskName",
"description": "taskDescription",
"skillsRequired": ["Heraldry"],
"currentState": "Created",
"reviewed": true
}
expect.assertions(1)
const task = await axios.post("http://localhost:3000/api/tasks",body)
expect(task.status).toEqual(200)
});
test('Delete a user', async () => {
body ={
"firstName": "John",
"lastName": "Doe",
"age": 12,
"email": "[email protected]",
"password": "12345"
}
expect.assertions(1)
const user = await axios.post("http://localhost:3000/api/users",body)
const deletedUser await axios.delete("http://localhost:3000/api/users/${user.data.data._id}")
expect(deletedUser.status).toEqual(200)
});
test('Delete a masterclass', async () => {
body ={
"name": "masterclassName",
"description": "masterclassDescription",
}
expect.assertions(1)
const masterclass = await axios.post("http://localhost:3000/api/masterclasses",body)
const deletedMasterclass = await axios.delete("http://localhost:3000/api/masterclasses/${masterclass.data.data._id}")
expect(deletedMasterclass.status).toEqual(200)
});
test('Adding user as an applicant to a task', async () => {
body ={
"name": "taskName",
"description": "taskDescription",
"skillsRequired": ["Heraldry"],
"currentState": "Created",
"reviewed": true
}
body2 ={
"firstName": "John",
"lastName": "Doe",
"age": 12,
"email": "[email protected]",
"password": "12345"
}
expect.assertions(1)
const task = await axios.post("http://localhost:3000/api/tasks",body)
const user = await axios.post("http://localhost:3000/api/users",body2)
const updatedTask = await axios.put("http://localhost:3000/api/tasks/${task.data.data._id}/${user.data.data._id}")
await axios.delete(`http://localhost:3000/api/tasks/${task.data.data._id}`)
expect(updatedTask.status).toEqual(200)
});
test(`Getting a certain task`, async () => {
expect.assertions(1)
const task = await funcs.getTask()
expect(task.data.name).toEqual('Task1')
});
test('Updating consultancy agency info', async () => {
body ={
"firstName": "John",
"lastName": "Doe",
"age": 12,
"email": "[email protected]",
"password": "12345"
"consultancyAgency": true
}
expect.assertions(1)
const user = await axios.post("http://localhost:3000/api/users",body)
const updatedUser = await axios.put("http://localhost:3000/api/users/${user.data.data._id}",{"consultancyInfo": "NewInfo"})
await axios.delete("http://localhost:3000/api/users/${user.data.data._id}")
expect(updatedUser.status).toEqual(200)
});
test('Delete a task', async () => {
body ={
"name": "taskName",
"description": "taskDescription",
"skillsRequired": ["Heraldry"],
"currentState": "Created",
"reviewed": true
}
expect.assertions(1)
const task = await axios.post("http://localhost:3000/api/tasks",body)
const deletedTask = await axios.delete(http://localhost:3000/api/tasks/${task.data.data._id})
expect(deletedTask.status).toEqual(200)
});