-
Notifications
You must be signed in to change notification settings - Fork 1
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
Update events function #39
base: master
Are you sure you want to change the base?
Conversation
…rror middlewares, and added route testing for the 404 display page and the home display page.
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.
Separate queries into database/queries
or what you think is equivalent, so you don't have to copy-paste your queries from and into different folders, just reuse them.
DO NOT TEST FOR HTML
And spend sometime on your HTML/CSS.
src/controllers/update_events.js
Outdated
const dbConnection = require('../database/db_connect'); | ||
|
||
exports.post = (req, res, next) => { | ||
Events.findByIdAndUpdate(req.params.id, |
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.
Split file to src/controllers
and src/database/queries
;
<section> | ||
<div class="headline"> | ||
<h3>Welcome to the GazaSkyGeeks Narrowcast</h3> | ||
<button type="button" id="#narrow-button" class="narrow-button">See narrowcast</button> |
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.
Don't use #
in an id
selector.
</div> | ||
|
||
<div class="programs-container"> | ||
<button type="button" id="view-programs" class="button" name="view programs">Programs</button> |
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.
use less id
s and more class
s.
src/views/update_events.hbs
Outdated
@@ -0,0 +1,53 @@ | |||
<h1>add events here</h1> | |||
<form class="" method="post"> | |||
<div class=""> |
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.
class=""
?
src/views/update_events.hbs
Outdated
<button type="submit" name="button" id="add-events">add events</button> | ||
</form> | ||
|
||
<p class="ss" id="ss"> |
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.
Use less id
s and more class
s.
.expect('content-type', 'text/html; charset=utf-8') | ||
.end((err, res) => { | ||
if (err) t.error(err); | ||
t.equal(res.text.includes('Page Not Found'), true, 'error should inform the user that the page is not found'); |
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 don't have to test HTML, just having a response of 404
is enough to say that this test does what it should.
test/controllers/home.js
Outdated
.expect('x-powered-by', 'Express') | ||
.end((err, res) => { | ||
t.error(err); | ||
t.equal(Object.values(res.headers).indexOf('Express') > -1, true, 'headers should include the express technology'); |
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.
So you already said .expect('x-powered-by', 'Express')
but then you make another equal to check that the headers actually contain Express
? What's so important about 'x-powered-by', 'Express'
That you want to make sure its there so bad?
test/controllers/update_events.js
Outdated
.expect(200) | ||
.end((err, res) => { | ||
if (err) return t.error(err); | ||
t.equal(JSON.stringify(res).includes('</form>'), true, 'render response should include a form element'); |
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.
Again, you don't have to validate HTML
.
test/controllers/update_events.js
Outdated
.expect(200) | ||
.end((err, response) => { | ||
if (err) t.end(err); | ||
t.equal(JSON.stringify(response).includes('new people'), true, '2nd coding for everyone should be updated to the new event with new people as speakers'); |
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.
DO NOT TEST FOR HTML!
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.
Man I spent 4 hours trying to access the supertest response object down to the key that holds the information I want and couldn't. I don't know how to test for it the way I want to.
test/tests_index.js
Outdated
.then(() => { | ||
// testing the update event controller | ||
require('./controllers/update_events'); | ||
}); |
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.
What if an error happened somewhere above? What would catch it?
…ler and usable anywhere, with proper validation in the backend, no frontend validation yet
…ultiple events per day
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.
Fix what's already been commented and push, then we'll see. Good luck.
@@ -0,0 +1,2 @@ | |||
PORT = 3000 |
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.
Do not push the config.env
viewEvents.addEventListener('click', () => { | ||
fetch('/events') | ||
.then(() => { | ||
window.location = '/events'; |
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 could've made it just an href
, why make an eventListener
?
@@ -0,0 +1,32 @@ | |||
const query = require('../database/queries/update_events_query'); |
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.
Name your query something more readable. Like, what is it responsible for? and then ask yourself, what does this query do? What is it's input and what's the output? Your name should be very specific, and your input should be very relevant, convince me why is your query taking { params: req.params, body: req.body }
not just { id }
.
@@ -0,0 +1,30 @@ | |||
const Events = require('../event_schema'); | |||
|
|||
const query = (req, callback) => { |
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.
And what does this query
do exactly? Can't I understand it's purpose from the name? And what is the req
it's taking as input?
if (err) return err; | ||
callback(); | ||
}) | ||
.then(() => { |
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.
then what?
No description provided.