diff --git a/src/test/simulation.js b/src/test/simulation.js index 8804b4359187953f1fd13584a36d7dc167139681..c74ca3ae0c8d47171c7ab402d9e6ff460dcc46a5 100644 --- a/src/test/simulation.js +++ b/src/test/simulation.js @@ -28,392 +28,6 @@ const User = require('../libs/models/user'); chai.use(chaiHttp); -describe('API is running', () => { - it('should respond it\'s running', (done) => { - chai.request(server) - .get('/api/v1') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('msg'); - done(); - }) - }); -}); - -describe('request enrollments', () => { - it('should list the year range', (done) => { - chai.request(server) - .get('/api/v1/enrollment/year_range') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('start_year'); - res.body.result[0].should.have.property('end_year'); - done(); - }); - }); - - it('should list the education level', (done) => { - chai.request(server) - .get('/api/v1/enrollment/education_level') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('id'); - res.body.result[0].should.have.property('name'); - done(); - }); - }); - - it('should list the administrative dependencies', (done) => { - chai.request(server) - .get('/api/v1/enrollment/adm_dependency ') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('id'); - res.body.result[0].should.have.property('name'); - done(); - }); - }); - - it('should list enrollments', (done) => { - chai.request(server) - .get('/api/v1/enrollment') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('name'); - res.body.result[0].should.have.property('total'); - done(); - }); - }); - - it('should list enrollments with valid filters', (done) => { - chai.request(server) - .get('/api/v1/enrollment?filter=min_year:2010,state:41') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('name'); - res.body.result[0].should.have.property('total'); - done(); - }); - }); - - it('should list enrollments with invalid filters', (done) => { - chai.request(server) - .get('/api/v1/enrollment?filter=foo:2010,bar:41') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('name'); - res.body.result[0].should.have.property('total'); - done(); - }); - }); - - it('should list enrollments with valid dimensions', (done) => { - chai.request(server) - .get('/api/v1/enrollment?dims=region,state,adm_dependency,location&filter=min_year:2014,region:4') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('region_name'); - res.body.result[0].should.have.property('state_name'); - res.body.result[0].should.have.property('adm_dependency_name'); - res.body.result[0].should.have.property('location_name'); - res.body.result[0].should.have.property('total'); - done(); - }); - }); - - it('should list enrollments with invalid dimensions', (done) => { - chai.request(server) - .get('/api/v1/enrollment?dims=foo,bar') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('name'); - res.body.result[0].should.have.property('total'); - done(); - }); - }); - - it('should list enrollments with valid dimensions and filters', (done) => { - chai.request(server) - .get('/api/v1/enrollment?dims=region,state,education_level,school&filter=min_year:2013,max_year:2014,city:4106902') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('region_name'); - res.body.result[0].should.have.property('state_name'); - res.body.result[0].should.have.property('school_name'); - res.body.result[0].should.have.property('education_level'); - res.body.result[0].should.have.property('total'); - res.body.result[0].should.have.property('year'); - done(); - }); - }); - - it('should list enrollments using all dimensions and filters', (done) => { - chai.request(server) - .get('/api/v1/enrollment?dims=region,state,city,education_level,school,adm_dependency,location&filter=min_year:2013,max_year:2014,city:4106902,adm_dependency:3,location:1,education_level:99') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('region_name'); - res.body.result[0].should.have.property('state_name'); - res.body.result[0].should.have.property('school_name'); - res.body.result[0].should.have.property('education_level'); - res.body.result[0].should.have.property('location_name'); - res.body.result[0].should.have.property('adm_dependency_name'); - res.body.result[0].should.have.property('total'); - res.body.result[0].should.have.property('year'); - done(); - }); - }); - - -}); - -describe('request regions', () => { - it('should list all regions', (done) => { - chai.request(server) - .get('/api/v1/region') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('pk_regiao_id'); - res.body.result[0].should.have.property('nome'); - done(); - }); - }); - - it('should list region by id', (done) => { - chai.request(server) - .get('/api/v1/region/1') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result.should.have.length(1); - res.body.result[0].should.have.property('pk_regiao_id'); - res.body.result[0].should.have.property('nome'); - done(); - }); - }); -}); - -describe('request states', () => { - it('should list all states', (done) => { - chai.request(server) - .get('/api/v1/state') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('pk_estado_id'); - res.body.result[0].should.have.property('fk_regiao_id'); - res.body.result[0].should.have.property('nome'); - done(); - }); - }); - - it('should list a state by id', (done) => { - chai.request(server) - .get('/api/v1/state/11') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result.should.have.length(1); - res.body.result[0].should.have.property('pk_estado_id'); - res.body.result[0].should.have.property('fk_regiao_id'); - res.body.result[0].should.have.property('nome'); - done(); - }); - }); - - it('should list states by region id', (done) => { - chai.request(server) - .get('/api/v1/state/region/1') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('pk_estado_id'); - res.body.result[0].should.have.property('fk_regiao_id'); - res.body.result[0].should.have.property('nome'); - done(); - }); - }); -}); - -describe('request cities', () => { - it('should list all cities', (done) => { - chai.request(server) - .get('/api/v1/city') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('pk_cod_ibge'); - res.body.result[0].should.have.property('nome'); - res.body.result[0].should.have.property('fk_estado_id'); - done(); - }); - }); - - it('should list a city by id', (done) => { - chai.request(server) - .get('/api/v1/city/4106902') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('pk_cod_ibge'); - res.body.result[0].should.have.property('fk_estado_id'); - res.body.result[0].should.have.property('nome'); - done(); - }); - }); - - it('should list a city by codigo_ibge', (done) => { - chai.request(server) - .get('/api/v1/city/ibge/4106902') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('pk_cod_ibge'); - res.body.result[0].should.have.property('fk_estado_id'); - res.body.result[0].should.have.property('nome'); - done(); - }); - }); - - it('should list all cities from a state', (done) => { - chai.request(server) - .get('/api/v1/city/state/41') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('pk_cod_ibge'); - res.body.result[0].should.have.property('fk_estado_id'); - res.body.result[0].should.have.property('nome'); - done(); - }) - }) -}); - -describe('request schools', () => { - it('should list a school by id', (done) => { - chai.request(server) - .get('/api/v1/school/41000021') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('ano_censo'); - res.body.result[0].should.have.property('cod_entidade'); - done(); - }); - }); - - it('should list all schools from a state', (done) => { - chai.request(server) - .get('/api/v1/school/state/41') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('cod_entidade'); - res.body.result[0].should.have.property('ano_censo'); - done(); - }); - }); - - it('should list all schools from a city', (done) => { - chai.request(server) - .get('/api/v1/school/city/4106902') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('cod_entidade'); - res.body.result[0].should.have.property('ano_censo'); - done(); - }) - }) -}); - -describe('test response', () => { - it('should list all regions in json', (done) => { - chai.request(server) - .get('/api/v1/region') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - done(); - }); - }); - - it('should list all regions in xml', (done) => { - chai.request(server) - .get('/api/v1/region?format=xml') - .end((err, res) => { - res.should.have.status(200); - res.should.be.xml; - done(); - }); - }); - - it('should list all regions in csv', (done) => { - chai.request(server) - .get('/api/v1/region?format=csv') - .end((err, res) => { - res.should.have.status(200); - done(); - }); - }); -}); - describe('Requires a simulation', () => { let newSimulation; @@ -792,468 +406,3 @@ describe('Requires a simulation', () => { }); }); }); - -describe('Saves a user', () => { - - beforeEach(() => { - User.remove({}, (err) => { - if(err) { - console.log('Error while purging: ' + err); - } - console.log('Test collection purged'); - }); - }); - - it('should create a new user', (done) => { - chai.request(server) - .post('/api/v1/user') - .set('content-type', 'application/x-www-form-urlencoded') - .set('x-apicache-bypass', 'true') - .send({email: 'lorem@ipsum.com', - password: '123mudar', - name: 'Tequila Baby', - cpf: '48303270737', - schooling: 'Doutorado', - course: 'Ciência da Computação', - segment: 'Comunidade acadêmica', - role: 'Pesquisador', - institution_name: 'UFPR', - state: 'PR', - city: 'Cutiriba'}) - .end((err, res) =>{ - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('success'); - res.body.success.should.equal(true); - User.findOne({'email': 'lorem@ipsum.com'}, (err, user) => { - if (err){ - console.log('MongoDB error: ' + err); - } - - user.should.have.property('email'); - done(); - }); - }); - }); - - it('should not create a user with an email that is already in use', (done) => { - let newUser = new User(); - - newUser.email = 'lorem@ipsum.com'; - newUser.password = '123mudar'; - newUser.name = 'Gute'; - newUser.cpf = '08236017907'; - newUser.schooling = 'Doutorado'; - newUser.course = 'Ciência da Computação'; - newUser.segment = 'Comunidade acadêmica'; - newUser.role = 'Pesquisador'; - newUser.institution_name = 'UFPR'; - newUser.state = 'PR'; - newUser.city = 'Curitiba'; - - newUser.save((err) => { - if (err) { - console.log('MongoDB error:' + err); - } - }).then(function(newuser){ - chai.request(server) - .post('/api/v1/user') - .set('content-type', 'application/x-www-form-urlencoded') - .set('x-apicache-bypass', 'true') - .send({email: 'lorem@ipsum.com', - password: '123mudar', - name: 'Tequila Baby', - cpf: '48303270737', - schooling: 'Doutorado', - course: 'Ciência da Computação', - segment: 'Comunidade acadêmica', - role: 'Pesquisador', - institution_name: 'UFPR', - state: 'PR', - city: 'Cutiriba'}) - .end((err, res) =>{ - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('success'); - res.body.success.should.equal(false); - res.body.should.have.property('msg'); - res.body.msg.should.equal('O email informado já está cadastrado.'); - User.findOne({'cpf': '48303270737'}, (err, user) => { - expect(user).to.not.exist; - done(); - }); - }); - }); - }); - - it('should not create a user with a CPF that is already in use', (done) => { - let newUser = new User(); - - newUser.email = 'lorem@ipsum.com'; - newUser.password = '123mudar'; - newUser.name = 'Gute'; - newUser.cpf = '08236017907'; - newUser.schooling = 'Doutorado'; - newUser.course = 'Ciência da Computação'; - newUser.segment = 'Comunidade acadêmica'; - newUser.role = 'Pesquisador'; - newUser.institution_name = 'UFPR'; - newUser.state = 'PR'; - newUser.city = 'Curitiba'; - - newUser.save((err) => { - if (err) { - console.log('MongoDB error:' + err); - } - }).then(function(newuser){ - chai.request(server) - .post('/api/v1/user') - .set('content-type', 'application/x-www-form-urlencoded') - .set('x-apicache-bypass', 'true') - .send({email: 'dolor@ipsum.com', - password: '123mudar', - name: 'Tequila Baby', - cpf: '08236017907', - schooling: 'Doutorado', - course: 'Ciência da Computação', - segment: 'Comunidade acadêmica', - role: 'Pesquisador', - institution_name: 'UFPR', - state: 'PR', - city: 'Cutiriba'}) - .end((err, res) =>{ - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('success'); - res.body.success.should.equal(false); - res.body.should.have.property('msg'); - res.body.msg.should.equal('O CPF informado já está cadastrado.'); - User.findOne({'email': 'dolor@ipsum.com'}, (err, user) => { - expect(user).to.not.exist; - done(); - }); - }); - }); - }); - - it('should not save an user without email', (done) => { - chai.request(server) - .post('/api/v1/user') - .set('content-type', 'application/x-www-form-urlencoded') - .set('x-apicache-bypass', 'true') - .send({password: '123mudar', - name: 'Tequila Baby', - cpf: '48303270737', - schooling: 'Doutorado', - course: 'Ciência da Computação', - segment: 'Comunidade acadêmica', - role: 'Pesquisador', - institution_name: 'UFPR', - state: 'PR', - city: 'Cutiriba'}) - .end((err, res) =>{ - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('success'); - res.body.success.should.equal(false); - res.body.should.have.property('msg'); - res.body.msg.should.equal('O campo Email é obrigatório.'); - User.findOne({'cpf': '48303270737'}, (err, user) => { - expect(user).to.not.exist; - done(); - }); - }); - }); - - it('should not save an user without password', (done) => { - chai.request(server) - .post('/api/v1/user') - .set('content-type', 'application/x-www-form-urlencoded') - .set('x-apicache-bypass', 'true') - .send({email: 'lorem@ipsum.com', - name: 'Tequila Baby', - cpf: '48303270737', - schooling: 'Doutorado', - course: 'Ciência da Computação', - segment: 'Comunidade acadêmica', - role: 'Pesquisador', - institution_name: 'UFPR', - state: 'PR', - city: 'Cutiriba'}) - .end((err, res) =>{ - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('success'); - res.body.success.should.equal(false); - res.body.should.have.property('msg'); - res.body.msg.should.equal('O campo Senha é obrigatório.'); - User.findOne({'cpf': '48303270737'}, (err, user) => { - expect(user).to.not.exist; - done(); - }); - }); - }); - - it('should not save an user with invalid email', (done) => { - chai.request(server) - .post('/api/v1/user') - .set('content-type', 'application/x-www-form-urlencoded') - .set('x-apicache-bypass', 'true') - .send({email: 'notavalidemail', - password: '123mudar', - name: 'Tequila Baby', - cpf: '48303270737', - schooling: 'Doutorado', - course: 'Ciência da Computação', - segment: 'Comunidade acadêmica', - role: 'Pesquisador', - institution_name: 'UFPR', - state: 'PR', - city: 'Cutiriba'}) - .end((err, res) =>{ - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('success'); - res.body.success.should.equal(false); - res.body.should.have.property('msg'); - res.body.msg.should.equal('O email informado é inválido.'); - User.findOne({'cpf': '48303270737'}, (err, user) => { - expect(user).to.not.exist; - done(); - }); - }); - }); - - it('should not save an user without name', (done) => { - chai.request(server) - .post('/api/v1/user') - .set('content-type', 'application/x-www-form-urlencoded') - .set('x-apicache-bypass', 'true') - .send({email: 'lorem@ipsum.com', - password: '123mudar', - cpf: '48303270737', - schooling: 'Doutorado', - course: 'Ciência da Computação', - segment: 'Comunidade acadêmica', - role: 'Pesquisador', - institution_name: 'UFPR', - state: 'PR', - city: 'Cutiriba'}) - .end((err, res) =>{ - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('success'); - res.body.success.should.equal(false); - res.body.should.have.property('msg'); - res.body.msg.should.equal('O campo Nome é obrigatório.'); - User.findOne({'cpf': '48303270737'}, (err, user) => { - expect(user).to.not.exist; - done(); - }); - }); - }); - - it('should not save an user without CPF', (done) => { - chai.request(server) - .post('/api/v1/user') - .set('content-type', 'application/x-www-form-urlencoded') - .set('x-apicache-bypass', 'true') - .send({email: 'lorem@ipsum.com', - password: '123mudar', - name: 'Tequila baby', - schooling: 'Doutorado', - course: 'Ciência da Computação', - segment: 'Comunidade acadêmica', - role: 'Pesquisador', - institution_name: 'UFPR', - state: 'PR', - city: 'Cutiriba'}) - .end((err, res) =>{ - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('success'); - res.body.success.should.equal(false); - res.body.should.have.property('msg'); - res.body.msg.should.equal('O campo CPF é obrigatório.'); - User.findOne({'email': 'lorem@ipsum.com'}, (err, user) => { - expect(user).to.not.exist; - done(); - }); - }); - }); - - it('should not save an user without segment', (done) => { - chai.request(server) - .post('/api/v1/user') - .set('content-type', 'application/x-www-form-urlencoded') - .set('x-apicache-bypass', 'true') - .send({email: 'lorem@ipsum.com', - password: '123mudar', - name: 'Tequila baby', - schooling: 'Doutorado', - cpf: '48303270737', - course: 'Ciência da Computação', - role: 'Pesquisador', - institution_name: 'UFPR', - state: 'PR', - city: 'Cutiriba'}) - .end((err, res) =>{ - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('success'); - res.body.success.should.equal(false); - res.body.should.have.property('msg'); - res.body.msg.should.equal('O campo Segmento é obrigatório.'); - User.findOne({'email': 'lorem@ipsum.com'}, (err, user) => { - expect(user).to.not.exist; - done(); - }); - }); - }); - - it('should not save an user without schooling', (done) => { - chai.request(server) - .post('/api/v1/user') - .set('content-type', 'application/x-www-form-urlencoded') - .set('x-apicache-bypass', 'true') - .send({email: 'lorem@ipsum.com', - password: '123mudar', - name: 'Tequila baby', - cpf: '48303270737', - course: 'Ciência da Computação', - segment: 'Comunidade acadêmica', - role: 'Pesquisador', - institution_name: 'UFPR', - state: 'PR', - city: 'Cutiriba'}) - .end((err, res) =>{ - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('success'); - res.body.success.should.equal(false); - res.body.should.have.property('msg'); - res.body.msg.should.equal('O campo Escolaridade é obrigatório.'); - User.findOne({'email': 'lorem@ipsum.com'}, (err, user) => { - expect(user).to.not.exist; - done(); - }); - }); - }); - - it('should not save an user without role', (done) => { - chai.request(server) - .post('/api/v1/user') - .set('content-type', 'application/x-www-form-urlencoded') - .set('x-apicache-bypass', 'true') - .send({email: 'lorem@ipsum.com', - password: '123mudar', - name: 'Tequila baby', - schooling: 'Doutorado', - cpf: '48303270737', - course: 'Ciência da Computação', - segment: 'Comunidade acadêmica', - institution_name: 'UFPR', - state: 'PR', - city: 'Cutiriba'}) - .end((err, res) =>{ - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('success'); - res.body.success.should.equal(false); - res.body.should.have.property('msg'); - res.body.msg.should.equal('O campo Função é obrigatório.'); - User.findOne({'email': 'lorem@ipsum.com'}, (err, user) => { - expect(user).to.not.exist; - done(); - }); - }); - }); - - it('should not save an user without institution', (done) => { - chai.request(server) - .post('/api/v1/user') - .set('content-type', 'application/x-www-form-urlencoded') - .set('x-apicache-bypass', 'true') - .send({email: 'lorem@ipsum.com', - password: '123mudar', - name: 'Tequila baby', - schooling: 'Doutorado', - cpf: '48303270737', - course: 'Ciência da Computação', - segment: 'Comunidade acadêmica', - role: 'Pesquisador', - state: 'PR', - city: 'Cutiriba'}) - .end((err, res) =>{ - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('success'); - res.body.success.should.equal(false); - res.body.should.have.property('msg'); - res.body.msg.should.equal('O campo Instituição em que trabalha é obrigatório.'); - User.findOne({'email': 'lorem@ipsum.com'}, (err, user) => { - expect(user).to.not.exist; - done(); - }); - }); - }); - - it('should not save an user without city', (done) => { - chai.request(server) - .post('/api/v1/user') - .set('content-type', 'application/x-www-form-urlencoded') - .set('x-apicache-bypass', 'true') - .send({email: 'lorem@ipsum.com', - password: '123mudar', - name: 'Tequila baby', - schooling: 'Doutorado', - cpf: '48303270737', - course: 'Ciência da Computação', - segment: 'Comunidade acadêmica', - institution_name: 'UFPR', - role: 'Pesquisador', - state: 'PR'}) - .end((err, res) =>{ - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('success'); - res.body.success.should.equal(false); - res.body.should.have.property('msg'); - res.body.msg.should.equal('O campo Cidade é obrigatório.'); - User.findOne({'email': 'lorem@ipsum.com'}, (err, user) => { - expect(user).to.not.exist; - done(); - }); - }); - }); - - it('should not save an user without state', (done) => { - chai.request(server) - .post('/api/v1/user') - .set('content-type', 'application/x-www-form-urlencoded') - .set('x-apicache-bypass', 'true') - .send({email: 'lorem@ipsum.com', - password: '123mudar', - name: 'Tequila baby', - schooling: 'Doutorado', - cpf: '48303270737', - course: 'Ciência da Computação', - segment: 'Comunidade acadêmica', - institution_name: 'UFPR', - role: 'Pesquisador', - city: 'Cutiriba'}) - .end((err, res) =>{ - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('success'); - res.body.success.should.equal(false); - res.body.should.have.property('msg'); - res.body.msg.should.equal('O campo Estado é obrigatório.'); - User.findOne({'email': 'lorem@ipsum.com'}, (err, user) => { - expect(user).to.not.exist; - done(); - }); - }); - }); - -});