generated from agiledev-students-fall2023/generic-project-repository
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from agiledev-students-fall2023/update-add-exp…
…ense-api Update add expense api and added unit tests
- Loading branch information
Showing
6 changed files
with
116 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const chai = require('chai'); | ||
const chaiHttp = require('chai-http'); | ||
const app = require('../app'); | ||
const expect = chai.expect; | ||
|
||
chai.use(chaiHttp); | ||
|
||
describe('Add Expense API', () => { | ||
describe('POST /add-expense', () => { | ||
it('should return a success response', (done) => { | ||
let postData = { | ||
name: "Flights", | ||
amount: 100, | ||
date: "2023-11-13", | ||
personPaid: "Jane", | ||
peopleSplit: ["Jane", "Jack"], | ||
splitMethod: "equal", | ||
amountDetails: { "Jane": 50, "Jack": 50 } | ||
}; | ||
|
||
chai.request(app) | ||
.post('/add-expense') | ||
.send(postData) | ||
.end((err, res) => { | ||
expect(res).to.have.status(200); | ||
expect(res.body).to.be.a('object'); | ||
expect(res.body).to.have.property('status', 'Success'); | ||
expect(res.body).to.have.property('message'); | ||
expect(res.body.data).to.deep.equal(postData); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
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,25 @@ | ||
const chai = require('chai'); | ||
const chaiHttp = require('chai-http'); | ||
const app = require('../app'); | ||
const expect = chai.expect; | ||
|
||
chai.use(chaiHttp); | ||
|
||
describe('Event API', () => { | ||
describe('GET /event', () => { | ||
it('should get event details', (done) => { | ||
chai.request(app) | ||
.get('/event') | ||
.end((err, res) => { | ||
expect(res).to.have.status(200); | ||
expect(res.body).to.be.a('object'); | ||
expect(res.body).to.have.property('id'); | ||
expect(res.body).to.have.property('name'); | ||
expect(res.body).to.have.property('expenses'); | ||
expect(res.body.expenses).to.be.a('array'); | ||
expect(res.body.expenses).to.have.lengthOf(3); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
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