-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
122 lines (114 loc) · 3.48 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
const expect = require("chai").expect;
var adres = "localhost:3000";
const request = require("supertest").agent(adres);
describe("POST /api/mekanlar", function () {
it("Yeni mekan ekle:", async function () {
const response = await request.post("/api/mekanlar").send({
ad: "Starbucks",
adres: "Centrum Garden",
puan: 5,
imkanlar: "çay,kahve,pasta",
enlem: 37.83226584629666,
boylam: 30.524732239878013,
gunler1: "Pazartesi-Cuma",
acilis1: "9:00",
kapanis1: "23:00",
kapali1: false,
gunler2: "Cumartesi-Pazar",
acilis2: "11:00",
kapanis2: "17:00",
kapali2: false,
});
expect(response.status).to.eql(201);
process.env.mekanid = response.body._id;
});
});
describe("GET /api/mekanlar", function () {
it("Girilen konum civarındaki tüm mekanları listele:", async function () {
const response = await request.get("/api/mekanlar?enlem=37&boylam=35");
expect(response.status).to.eql(200);
});
});
describe("GET /api/mekanlar/:mekanid", function () {
it("Mekan getir:", async function () {
const response = await request.get(`/api/mekanlar/${process.env.mekanid}`);
expect(response.status).to.eql(200);
});
});
describe("PUT /api/mekanlar/:mekanid", function () {
it("Mekan Güncelle:", async function () {
const response = await request
.put(`/api/mekanlar/${process.env.mekanid}`)
.send({
ad: "Starbucks SDÜ",
adres: "SDÜ Doğu Kampüsü",
puan: 3,
imkanlar: "çay,kahve,pasta,refresher",
enlem: 37.8,
boylam: 30.5,
gunler1: "Pazartesi-Cuma",
acilis1: "9:10",
kapanis1: "23:10",
kapali1: true,
gunler2: "Cumartesi-Pazar",
acilis2: "11:10",
kapanis2: "17:10",
kapali2: true,
});
expect(response.status).to.eql(200);
});
});
describe("POST /api/mekanlar/:mekanid/yorumlar", function () {
it("Yorum ekle:", async function () {
const response = await request
.post(`/api/mekanlar/${process.env.mekanid}/yorumlar`)
.send({
yorumYapan: "ASY",
puan: 5,
yorumMetni: "Kahveler harika",
});
process.env.yorumid = response.body._id;
expect(response.status).to.eql(201);
});
});
describe("GET /api/mekanlar/:mekanid/yorumlar/:yorumid", function () {
it("Yorum getir:", async function () {
const response = await request.get(
`/api/mekanlar/${process.env.mekanid}/yorumlar/${process.env.yorumid}`
);
expect(response.status).to.eql(200);
});
});
describe("PUT /api/mekanlar/:mekanid/yorumlar/:yorumid", function () {
it("Yorum güncelle:", async function () {
const response = await request
.put(
`/api/mekanlar/${process.env.mekanid}/yorumlar/${process.env.yorumid}`
)
.send({
yorumYapan: "Sinan",
puan: 4,
yorumMetni: "Kahveler harikaaaa",
});
expect(response.status).to.eql(200);
});
});
describe("DELETE /api/mekanlar/:mekanid/yorumlar/:yorumid", function () {
it("Yorum sil:", async function () {
const response = await request.delete(
`/api/mekanlar/${process.env.mekanid}/yorumlar/${process.env.yorumid}`
);
expect(response.status).to.eql(200);
});
});
describe("DELETE /api/mekanlar/:mekanid", function () {
it("Mekan sil:", async function () {
const response = await request.delete(
`/api/mekanlar/${process.env.mekanid}`
);
expect(response.status).to.eql(200);
});
});
after((done) => {
done();
});