-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adicionando testes da parte de admini
- Loading branch information
Showing
2 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
}) | ||
}) | ||
}) |