Commit 83fbfa39 authored by arcter's avatar arcter
Browse files

Added mentor's & accepted's tests

parent e2a1d4f7
Pipeline #4688 failed with stages
in 3 minutes and 25 seconds
......@@ -13,10 +13,10 @@ const fakeUserJson = {
fullName: 'faker Janos',
secondaryEmail: 'faker@fake.com',
}
let fakeTasksJson={
let fakeTaskJson={
title:"The greatest task",
description:'Ezt kell csinálni a greatest tasknál',
deadLine:"2020.12.31",
deadline:"2020.12.31",
createData:"CreateData",
bit:"10",
......@@ -25,10 +25,9 @@ let fakeTasksJson={
_id:true,
title:true,
description:true,
deadLine:true,
deadline:true,
createData:true,
bit:true,
createData:true
}
describe('/task "Mentor" Functionality', () => {
......@@ -42,7 +41,56 @@ let fakeTasksJson={
return done()
})
})
//readone
test(`GET existing task`, async () => {
const newTask = await Task.create(fakeTaskJson)
let response = await authSession.get(`${endpointUrl}/${newTask._id}`)
expect(response.statusCode).toBe(200)
})
test('GET invalid task',async()=>{
let response=await authSession.get(`${endpointUrl}/almafa`)
expect(response.statusCode).toBe(422)
})
// Get Many
test(`GET many returns with allowed keys`, async () => {
await Task.create(fakeTaskJson)
await Task.create(fakeTaskJson)
let response = await authSession.get(endpointUrl)
expect(response.statusCode).toBe(200)
response.body.data.forEach((eachData) => {
validateKeys(eachData, defaultKeys)
})
})
// Create
test(`Create task`, async () => {
const newTask = await Task.create(fakeTaskJson)
let response =await authSession.post(`${endpointUrl}/`).send({
title:newTask.title,
description:newTask.description,
deadline:newTask.deadline,
createData:newTask.createData,
bit:newTask.bit,
})
expect(response.statusCode).toBe(201)
validateKeys(response.body.data, defaultKeys)
})
//Update
test(`Update task`,async()=>{
const newTask=await Task.create(fakeTaskJson)
let response=await authSession
.put(`${endpointUrl}/${newTask._id}`)
.send({
title:'updatedtitle',
})
expect(response.statusCode).toBe(200)
expect(response.body.data.title).toBe('updatedtitle')
})
//Delete
test(`Delete task`,async ()=>{
const newTask = await Task.create(fakeTaskJson)
let response=await authSession.delete(`${endpointUrl}/${newTask._id}`)
expect(response.statusCode).toBe(200)
})
})
//Nem számít az ,hogy melyikkel teszteled mert mind2nak ugyan olyannak kell lennie.
//normal=accepted
......@@ -57,5 +105,24 @@ let fakeTasksJson={
return done()
})
})
//readone
test(`GET existing task`, async () => {
const newTask = await Task.create(fakeTaskJson)
let response = await authSession.get(`${endpointUrl}/${newTask._id}`)
expect(response.statusCode).toBe(200)
})
test('GET invalid task',async()=>{
let response=await authSession.get(`${endpointUrl}/almafa`)
expect(response.statusCode).toBe(422)
})
// Get Many
test(`GET many returns with allowed keys`, async () => {
await Task.create(fakeTaskJson)
await Task.create(fakeTaskJson)
let response = await authSession.get(endpointUrl)
expect(response.statusCode).toBe(200)
response.body.data.forEach((eachData) => {
validateKeys(eachData, defaultKeys)
})
})
})
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment