Commit f4fd12b8 authored by rlacko's avatar rlacko 💬
Browse files

remove createData from defaultKeys

parent 8c1b6763
Pipeline #4720 passed with stages
in 2 minutes and 8 seconds
......@@ -4,33 +4,30 @@ const { merge, has } = require('lodash')
const { validateKeys } = require('../../../utils/testHelpers')
const { User } = require('../../user/userModel')
const {Task}= require('../taskModel')
const { Task } = require('../taskModel')
const endpointUrl = '/api/v1/task'
const fakeUserJson = {
internal_id: 'fakeId',
schacc: 'fakeUser',
fullName: 'faker Janos',
secondaryEmail: 'faker@fake.com',
}
let fakeTaskJson={
title:"The greatest task",
description:'Ezt kell csinálni a greatest tasknál',
deadline:"2020.12.31",
createData:"CreateData",
bit:"10",
internal_id: 'fakeId',
schacc: 'fakeUser',
fullName: 'faker Janos',
secondaryEmail: 'faker@fake.com',
}
let fakeTaskJson = {
title: 'The greatest task',
description: 'Ezt kell csinálni a greatest tasknál',
deadline: '2020.12.31',
bit: '10',
}
const defaultKeys = {
_id: true,
title: true,
description: true,
deadline: true,
bit: true,
}
}
const defaultKeys={
_id:true,
title:true,
description:true,
deadline:true,
createData:true,
bit:true,
}
describe('/task "Mentor" Functionality', () => {
describe('/task "Mentor" Functionality', () => {
let authSession
// Login as mentor
beforeEach(async function (done) {
......@@ -41,60 +38,58 @@ let fakeTaskJson={
return done()
})
})
//readone
//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`)
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)
})
// 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
})
// 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,
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',
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 ()=>{
test(`Delete task`, async () => {
const newTask = await Task.create(fakeTaskJson)
let response=await authSession.delete(`${endpointUrl}/${newTask._id}`)
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.
})
//Nem számít az ,hogy melyikkel teszteled mert mind2nak ugyan olyannak kell lennie.
//normal=accepted
describe('/task "Accepted" Functionality', () => {
describe('/task "Accepted" Functionality', () => {
let authSession
// Login as accepted and create a group
beforeEach(async function (done) {
......@@ -105,24 +100,24 @@ let fakeTaskJson={
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)
})
})
//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