98 lines
2.6 KiB
JavaScript
98 lines
2.6 KiB
JavaScript
const request = require('supertest')
|
|
const app = require('../server')
|
|
const userInfo = require('./userInfo')
|
|
describe('END-POINT project', () => {
|
|
let newID="";
|
|
var auth = {accessToken:""};
|
|
|
|
it("Login", async () => {
|
|
const login = await request(app)
|
|
.post('/auth')
|
|
.send({
|
|
email: userInfo.email,
|
|
password: userInfo.password
|
|
});
|
|
if(login.statusCode==201){
|
|
auth = login.body;
|
|
console.log(auth.accessToken);
|
|
}
|
|
expect(login.statusCode).toEqual(201)
|
|
})
|
|
it("POST '/project/'", async () => {
|
|
const res = await request(app)
|
|
.post('/project')
|
|
.auth(auth.accessToken, { type: 'bearer' })
|
|
.send({
|
|
"projectName":"deserunt",
|
|
"details":"Nisi voluptate sint voluptate excepteur amet veniam non laboris duis.",
|
|
"basePath":"velit"
|
|
})
|
|
expect(res.statusCode).toEqual(200)
|
|
newID=res.statusCode==200?res.body["id"]:"";
|
|
|
|
})
|
|
it("POST '/project/'", async () => {
|
|
const res = await request(app)
|
|
.post('/project')
|
|
.auth(auth.accessToken, { type: 'bearer' })
|
|
.send({
|
|
"projectName":"adclf",
|
|
"details":"Quis pariatur cupidatat veniam est magna est aliquip sit cillum enim occaecat incididunt nulla exercitation sunt.",
|
|
"basePath":"enim"
|
|
})
|
|
expect(res.statusCode).toEqual(200)
|
|
newID=res.statusCode==200?res.body["id"]:"";
|
|
|
|
})
|
|
it("GET '/project/'", async () => {
|
|
const res = await request(app)
|
|
.get('/project?projectName=deserunt&details=Nisi volup&basePath=velit')
|
|
.auth(auth.accessToken, { type: 'bearer' })
|
|
.send()
|
|
expect(res.statusCode).toEqual(200)
|
|
|
|
})
|
|
|
|
it("GET '/project/"+newID+"'", async () => {
|
|
if(newID!=""){
|
|
const res = await request(app)
|
|
.get('/project/'+newID)
|
|
.auth(auth.accessToken, { type: 'bearer' })
|
|
.send()
|
|
expect(res.statusCode).toEqual(200)
|
|
}else{
|
|
console.log("**GET[ID] TEST HAS BEEN SKIPED")
|
|
}
|
|
|
|
})
|
|
it("PATCH '/project/"+newID+"'", async () => {
|
|
if(newID!=""){
|
|
const res = await request(app)
|
|
.patch('/project/'+newID)
|
|
.auth(auth.accessToken, { type: 'bearer' })
|
|
.send({
|
|
"projectName":"nonclf",
|
|
"details":"Anim magna eiusmod dolor aute labore deserunt eu amet.",
|
|
"basePath":"culpa"
|
|
})
|
|
expect(res.statusCode).toEqual(204)
|
|
}else{
|
|
console.log("**PATCH TEST HAS BEEN SKIPED")
|
|
}
|
|
})
|
|
|
|
it("DELETE '/project/"+newID+"'", async () => {
|
|
if(newID!=""){
|
|
const res = await request(app)
|
|
.delete('/project/'+newID)
|
|
.auth(auth.accessToken, { type: 'bearer' })
|
|
.send()
|
|
expect(res.statusCode).toEqual(204)
|
|
}else{
|
|
console.log("**DELETE TEST HAS BEEN SKIPED")
|
|
}
|
|
})
|
|
|
|
})
|
|
|