Skip to content
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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Update events function #39

wants to merge 12 commits into from

Conversation

FarahZaqout
Copy link
Member

No description provided.

…rror middlewares, and added route testing for the 404 display page and the home display page.
Copy link
Contributor

@NouraldinS NouraldinS left a 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.

const dbConnection = require('../database/db_connect');

exports.post = (req, res, next) => {
Events.findByIdAndUpdate(req.params.id,
Copy link
Contributor

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>
Copy link
Contributor

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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use less ids and more classs.

@@ -0,0 +1,53 @@
<h1>add events here</h1>
<form class="" method="post">
<div class="">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class="" ?

<button type="submit" name="button" id="add-events">add events</button>
</form>

<p class="ss" id="ss">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use less ids and more classs.

.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');
Copy link
Contributor

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.

.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');
Copy link
Contributor

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?

.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');
Copy link
Contributor

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.

.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');
Copy link
Contributor

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!

Copy link
Member Author

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.

.then(() => {
// testing the update event controller
require('./controllers/update_events');
});
Copy link
Contributor

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?

Copy link
Contributor

@NouraldinS NouraldinS left a 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
Copy link
Contributor

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';
Copy link
Contributor

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');
Copy link
Contributor

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) => {
Copy link
Contributor

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(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then what?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants