-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(payloads): singularize payload name on event, product and venue (#…
…25) * fix(models): improve CRUD logic on events and make new populations * fix(payloads): singularize payload name on event, product and venue BREAKING CHANGE: payloads related
- Loading branch information
Showing
13 changed files
with
129 additions
and
51 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
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
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
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
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
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
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,73 @@ | ||
const sinon = require('sinon'); | ||
const chai = require('chai'); | ||
const chaiAsPromised = require('chai-as-promised'); | ||
const chaiHttp = require('chai-http'); | ||
const app = require('../../../index'); | ||
const Account = require('../../../api/controllers/account'); | ||
const JWT = require('../../../api/lib/auth'); | ||
|
||
chai.use(chaiAsPromised); | ||
chai.use(chaiHttp); | ||
const expect = chai.expect; | ||
const request = chai.request; | ||
|
||
describe('Account Controller', () => { | ||
describe('/GET account', () => { | ||
it('should get the account with valid token', async () => { | ||
const token = `Bearer ${JWT.create({ | ||
data: '5b6f49230619fc36cde7424b' | ||
})}`; | ||
const res = await request(app) | ||
.get('/account/') | ||
.set('Authorization', token); | ||
expect(res.status).to.be.equal(200); | ||
}); | ||
|
||
it('should get unauthorized response without token', async () => { | ||
const res = await request(app).get('/account/'); | ||
expect(res.status).to.be.equal(403); | ||
}); | ||
}); | ||
|
||
describe('POST account', () => { | ||
it('should avoid create a existent user', async () => { | ||
const user = { | ||
firstName: 'felipe', | ||
lastName: 'janer', | ||
password: '123', | ||
email: 'f@cymbals.com' | ||
}; | ||
const res = await request(app) | ||
.post('/account') | ||
.send(user); | ||
expect(res.status).to.be.equal(400); | ||
expect(res.body).to.be.a('object'); | ||
expect(res.body).to.have.property('error'); | ||
}); | ||
}); | ||
|
||
describe('PUT account', () => { | ||
it('should update a existent user', async () => { | ||
const login = await request(app) | ||
.post('/auth') | ||
.send({ email: 'f@cymbals.com', password: '123' }); | ||
|
||
console.log(login); | ||
|
||
const token = `Bearer ${login.res}`; | ||
|
||
const user = { | ||
firstName: 'ronaldinho', | ||
lastName: 'janer', | ||
email: 'f@cymbals.com' | ||
}; | ||
const res = await request(app) | ||
.put('/account') | ||
.send(user) | ||
.set('Authorization', token); | ||
expect(res.status).to.be.equal(200); | ||
expect(res.body).to.be.a('object'); | ||
expect(res.body).to.have.property('error'); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.