Skip to content

Commit

Permalink
Adicionando testes da parte de admini
Browse files Browse the repository at this point in the history
  • Loading branch information
angeliski committed Jan 22, 2018
1 parent 67069ff commit e319b9d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/api/admin/controller.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import Administrator from './model'
import { success } from './../../constants'

export const create = (req, res, next) =>
export const create = (req, res) =>
Administrator.create(new Administrator(req.body))
.then(admin => admin)
.then(success(res))
.catch(next)
.catch((err) => {
return res.status(500).json({
status: false,
data: err
})
})
30 changes: 30 additions & 0 deletions test/api/admin.integration.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import TestUtil from '../TestUtil'

describe('Admin', () => {
const request = TestUtil.requestApi('admin')

context('Post /', () => {
it('should persist the new admin', (done) => {
const admin = {
email: 'admin@admin.com.br'
}

request.post('/')
.send(admin)
.expect('Content-Type', /json/)
.expect(200)
.end(TestUtil.endTest.bind(null, done))
})

it('should return error when new admin not have email', (done) => {
const admin = {
}

request.post('/')
.send(admin)
.expect('Content-Type', /json/)
.expect(500)
.end(TestUtil.endTest.bind(null, done))
})
})
})

0 comments on commit e319b9d

Please sign in to comment.