Commit 55449775 authored by arcter's avatar arcter
Browse files

Add Mentor's mentor's tests

parent 83fbfa39
Pipeline #4702 passed with stages
in 2 minutes and 38 seconds
......@@ -14,7 +14,7 @@ const fakeUserJson = {
secondaryEmail: 'faker@fake.com',
}
let fakeMentorsJson={
user:fakeUserJson.schacc,
description:'Legjobb mentor ever',
}
const defaultKeys={
......@@ -35,7 +35,54 @@ let fakeMentorsJson={
return done()
})
})
//readone
test(`GET existing mentor`, async () => {
const newMentor = await Mentor.create(fakeMentorsJson)
let response = await authSession.get(`${endpointUrl}/${newMentor._id}`)
expect(response.statusCode).toBe(200)
})
test('GET invalid mentor',async()=>{
let response=await authSession.get(`${endpointUrl}/almafa`)
expect(response.statusCode).toBe(422)
})
// Get Many
test(`GET many returns with allowed keys`, async () => {
await Mentor.create(fakeMentorsJson)
await Mentor.create(fakeMentorsJson)
let response = await authSession.get(endpointUrl)
expect(response.statusCode).toBe(200)
response.body.data.forEach((eachData) => {
validateKeys(eachData, defaultKeys)
})
})
// Create
test(`Create mentor`, async () => {
const newUser = await User.create(fakeUserJson)
const newMentor = await Mentor.create(fakeMentorsJson)
let response =await authSession.post(`${endpointUrl}/`).send({
user:newUser.schacc,
description:'Legjobb mentor ever',
})
expect(response.statusCode).toBe(201)
validateKeys(response.body.data, defaultKeys)
})
//Update
test(`Update mentor`,async()=>{
const newMentor=await Mentor.create(fakeMentorsJson)
let response=await authSession
.put(`${endpointUrl}/${newMentor._id}`)
.send({
description:'updateddescription',
})
expect(response.statusCode).toBe(200)
expect(response.body.data.description).toBe('updateddescription')
})
//Delete
test(`Delete mentor`,async ()=>{
const newMentor = await Mentor.create(fakeMentorsJson)
let response=await authSession.delete(`${endpointUrl}/${newMentor._id}`)
expect(response.statusCode).toBe(200)
})
})
//Nem számít az ,hogy melyikkel teszteled mert mind2nak ugyan olyannak kell lennie.
//normal=accepted
......@@ -50,5 +97,26 @@ let fakeMentorsJson={
return done()
})
})
//readone
test(`GET existing mentor`, async () => {
const newUser= await User.create(fakeUserJson)
const newMentor = await Mentor.create(fakeMentorsJson)
let response = await authSession.get(`${endpointUrl}/${newMentor._id}`)
expect(response.statusCode).toBe(200)
})
test('GET invalid mentor',async()=>{
let response=await authSession.get(`${endpointUrl}/almafa`)
expect(response.statusCode).toBe(422)
})
// Get Many
test(`GET many returns with allowed keys`, async () => {
await Mentor.create(fakeMentorsJson)
await Mentor.create(fakeMentorsJson)
let response = await authSession.get(endpointUrl)
expect(response.statusCode).toBe(200)
response.body.data.forEach((eachData) => {
validateKeys(eachData, defaultKeys)
})
})
})
......@@ -2,8 +2,7 @@ const mongoose = require('mongoose')
const MentorSchema = new mongoose.Schema({
user: {
type: mongoose.Schema.Types.ObjectId,
ref: 'user',
type: String,
required: true,
},
description: {
......
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