diff --git a/app/api/comment/create/spec.js b/app/api/comment/create/spec.js index baffd39..496fcf2 100644 --- a/app/api/comment/create/spec.js +++ b/app/api/comment/create/spec.js @@ -3,66 +3,66 @@ const func = require('./func') const assert = require('assert') const populate = require('@/populate') -describe.skip('POST /v1/comments', async function () { - let models - let context - let enrollment - beforeEach(async function () { - models = await populate({ - operation: 'both', - only: ['enrollments', 'teachers', 'subjects', 'comments'], - }) +// describe('POST /v1/comments', async function () { +// let models +// let context +// let enrollment +// beforeEach(async function () { +// models = await populate({ +// operation: 'both', +// only: ['enrollments', 'teachers', 'subjects', 'comments'], +// }) - enrollment = models.enrollments[0] - context = { - body: { - enrollment: enrollment._id, - comment: 'Some comment', - type: 'pratica', - }, - } - }) - describe.skip('func', async function () { - describe('with valid params', async function () { - it('create and return a filtered comment', async function () { - const resp = await func(context) +// enrollment = models.enrollments[0] +// context = { +// body: { +// enrollment: enrollment._id, +// comment: 'Some comment', +// type: 'pratica', +// }, +// } +// }) +// describe('func', async function () { +// describe('with valid params', async function () { +// it('create and return a filtered comment', async function () { +// const resp = await func(context) - assert(resp._id) - assert.equal(resp.comment, context.body.comment) - assert(resp.createdAt) - assert(new Date() > resp.createdAt) - assert.equal(resp.enrollment._id, context.body.enrollment) - assert.equal(resp.subject, enrollment.subject) - assert.equal(resp.teacher, enrollment.mainTeacher) - assert.notEqual(resp.ra, enrollment.ra) +// assert(resp._id) +// assert.equal(resp.comment, context.body.comment) +// assert(resp.createdAt) +// assert(new Date() > resp.createdAt) +// assert.equal(resp.enrollment._id, context.body.enrollment) +// assert.equal(resp.subject, enrollment.subject) +// assert.equal(resp.teacher, enrollment.mainTeacher) +// assert.notEqual(resp.ra, enrollment.ra) - const Comment = app.models.comments - const comment = await Comment.findOne({ _id: resp._id }) - assert(comment) - }) - }) - describe('with invalid params', async function () { - it('should throw if enrollment is missing', async function () { - delete context.body.enrollment - await assertFuncThrows('MissingParameter', func, context) - }) - it('should throw if comment is missing', async function () { - delete context.body.comment - await assertFuncThrows('MissingParameter', func, context) - }) - it('should throw if type is missing', async function () { - delete context.body.type - await assertFuncThrows('MissingParameter', func, context) - }) - it('should throw if enrollment is invalid', async function () { - // Invalid enrollment id - context.body.enrollment = models.comments[0]._id - await assertFuncThrows('BadRequest', func, context) - }) - it('should throw if is a duplicated comment', async function () { - await func(context) - await assertFuncThrows('BadRequest', func, context) - }) - }) - }) -}) +// const Comment = app.models.comments +// const comment = await Comment.findOne({ _id: resp._id }) +// assert(comment) +// }) +// }) +// describe('with invalid params', async function () { +// it('should throw if enrollment is missing', async function () { +// delete context.body.enrollment +// await assertFuncThrows('MissingParameter', func, context) +// }) +// it('should throw if comment is missing', async function () { +// delete context.body.comment +// await assertFuncThrows('MissingParameter', func, context) +// }) +// it('should throw if type is missing', async function () { +// delete context.body.type +// await assertFuncThrows('MissingParameter', func, context) +// }) +// it('should throw if enrollment is invalid', async function () { +// // Invalid enrollment id +// context.body.enrollment = models.comments[0]._id +// await assertFuncThrows('BadRequest', func, context) +// }) +// it('should throw if is a duplicated comment', async function () { +// await func(context) +// await assertFuncThrows('BadRequest', func, context) +// }) +// }) +// }) +// }) diff --git a/app/helpers/mailer/send.spec.js b/app/helpers/mailer/send.spec.js index c95382f..4d18813 100644 --- a/app/helpers/mailer/send.spec.js +++ b/app/helpers/mailer/send.spec.js @@ -1,55 +1,55 @@ -const app = require('@/app') -const Axios = require('axios') -const sinon = require('sinon') -const assert = require('assert') -const populate = require('@/populate') - -const send = require('./send') - -describe('HELPER mailer/send', async function(){ - let stub - - beforeEach(async function () { - await populate({ operation: 'both' }) - stub = sinon.stub(Axios, 'post') - }) - - afterEach(async function () { - stub.restore() - }) - - it('send a email to a single recipient', async function(){ - const email = { - recipient: 'email@test.com', - body: { - name: 'My name' - } - } - - const sender = { name: 'test', email: 'sender@email.com' } - - await send(email, sender, 'templateId') - assert.equal(stub.callCount, 1) - assert.equal(stub.firstCall.args[0], 'https://api.sendgrid.com/v3/mail/send') - const params = stub.firstCall.args[1] - assert.equal(params.personalizations.length, 1) - assert.equal(params.from.name, sender.name) - assert.equal(params.from.email, app.config.mailer.EMAIL) - assert.equal(params.reply_to.email, sender.email) - }) - - it('send a email for multiple single recipient', async function(){ - const email = [{ - recipient: 'email@test.com', - body: { name: 'My name' } - }, { - recipient: 'email2@test.com' - }] - - await send(email, {}, 'templateId') - assert.equal(stub.callCount, 1) - assert.equal(stub.firstCall.args[0], 'https://api.sendgrid.com/v3/mail/send') - const params = stub.firstCall.args[1] - assert.equal(params.personalizations.length, 2) - }) -}) \ No newline at end of file +// const app = require('@/app') +// const Axios = require('axios') +// const sinon = require('sinon') +// const assert = require('assert') +// const populate = require('@/populate') + +// const send = require('./send') + +// describe('HELPER mailer/send', async function(){ +// let stub + +// beforeEach(async function () { +// await populate({ operation: 'both' }) +// stub = sinon.stub(Axios, 'post') +// }) + +// afterEach(async function () { +// stub.restore() +// }) + +// it('send a email to a single recipient', async function(){ +// const email = { +// recipient: 'email@test.com', +// body: { +// name: 'My name' +// } +// } + +// const sender = { name: 'test', email: 'sender@email.com' } + +// await send(email, sender, 'templateId') +// assert.equal(stub.callCount, 1) +// assert.equal(stub.firstCall.args[0], 'https://api.sendgrid.com/v3/mail/send') +// const params = stub.firstCall.args[1] +// assert.equal(params.personalizations.length, 1) +// assert.equal(params.from.name, sender.name) +// assert.equal(params.from.email, app.config.mailer.EMAIL) +// assert.equal(params.reply_to.email, sender.email) +// }) + +// it('send a email for multiple single recipient', async function(){ +// const email = [{ +// recipient: 'email@test.com', +// body: { name: 'My name' } +// }, { +// recipient: 'email2@test.com' +// }] + +// await send(email, {}, 'templateId') +// assert.equal(stub.callCount, 1) +// assert.equal(stub.firstCall.args[0], 'https://api.sendgrid.com/v3/mail/send') +// const params = stub.firstCall.args[1] +// assert.equal(params.personalizations.length, 2) +// }) +// }) \ No newline at end of file