-
Notifications
You must be signed in to change notification settings - Fork 4
Test for proposals #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 6 commits
bd5e341
b7a5823
ea1dcbb
6fba9b2
92e15ee
96cf6aa
3b456fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| 'use strict'; | ||
|
|
||
| const request = require('supertest'); | ||
| const app = require('../../server/server'); | ||
|
|
||
| describe('GET /api/proposals', () => { | ||
| it('respond with json', (done) => { | ||
| request(app) | ||
| .get('/api/proposals') | ||
| .set('Accept', 'application/json') | ||
| .expect('Content-Type', /json/, done) | ||
| .expect(200, done); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You may want to test that the response is an array of objects with the correct structure. That may involve creating some test data and then cleaning it up after the test. Ideally you would programmatically associate the proposal model with the memory datasource so don't have to worry about cleaning up the test data. |
||
| }); | ||
| }); | ||
|
|
||
| describe("POST /api/proposals/submit", () => { | ||
| it("Posts a new proposal to /api/proposals", (done) => { | ||
| let proposal = { | ||
| speakerName: "Danny", | ||
| speakerEmail: "danny@pham.com", | ||
| talkTitle: "Do this instead of that", | ||
| talkDescription: "That is so-so but this, this is revolutionary.", | ||
| } | ||
| request(app) | ||
| .post("/api/proposals/submit") | ||
| .send(proposal) | ||
| .expect(200, done); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You probably want to check the body of the response to make sure it echos what you expected. |
||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to boot the server in order for the loopback stuff to kick in. Add:
app.boot();