Giter Site home page Giter Site logo

frontend-nanodegree-feedreader's Introduction

Project Overview

In this project you are given a web-based application that reads RSS feeds. The original developer of this application clearly saw the value in testing, they've already included Jasmine and even started writing their first test suite! Unfortunately, they decided to move on to start their own company and we're now left with an application with an incomplete test suite. That's where you come in.

Why this Project?

Testing is an important part of the development process and many organizations practice a standard of development known as "test-driven development." This is when developers write tests first, before they ever start developing their application. All the tests initially fail and then they start writing application code to make these tests pass.

Whether you work in an organization that uses test-driven development or in an organization that uses tests to make sure future feature development doesn't break existing features, it's an important skill to have!

What will I learn?

You will learn how to use Jasmine to write a number of tests against a pre-existing application. These will test the underlying business logic of the application as well as the event handling and DOM manipulation.

How will this help my career?

Writing effective tests requires analyzing multiple aspects of an application including the HTML, CSS and JavaScript - an extremely important skill when changing teams or joining a new company.

Good tests give you the ability to quickly analyze whether new code breaks an existing feature within your codebase, without having to manually test all of the functionality.

Development Strategy

For a refresher (or reference) before you begin writing code, we recommend reviewing the content from JavaScript Testing. Your project will be evaluated by a Udacity code reviewer according to the Feed Reader Testing project rubric. Please review for detailed project requirements.

  1. Familiarize yourself with the starter code
    • Open up index.html and review the functionality of the application within your browser
    • What is all the code in app.js doing? Be sure to read all code comments
    • Check out style.css. How is styling applied to the application?
  2. Explore the Jasmine spec file in feedreader.js
    • This is the file in which you'll be writing your tests
    • Make sure to read all code comments here as well
    • Review the Jasmine documentation if needed
  3. Edit the allFeeds variable in app.js to make the provided test fail
    • See how Jasmine visualizes this failure in your application
    • Return the allFeeds variable to a passing state after reviewing the failed test
  4. Write a test that loops through each feed in the allFeeds object and ensures it has a URL defined and that the URL is not empty
    • For example, how would you use a for...of loop in this test?
  5. Write a test that loops through each feed in the allFeeds object and ensures it has a name defined and that the name is not empty
    • Think about how you wrote the previous test. What are you testing for this time?
  6. Write a new test suite named "The menu"
    • What are you describe-ing in this test suite?
  7. Write a test that ensures the menu element is hidden by default
    • You'll have to analyze the HTML and the CSS to determine how the hiding/showing of the menu element is implemented
    • What code in app.js is directly involved with toggling the menu on and off?
  8. Write a test that ensures the menu changes visibility when the menu icon is clicked. This test should have two expectations: does the menu display itself when clicked, and does it hide when clicked again?
    • Think about how you wrote the previous test. What is different this time around?
    • Which clickable element are you checking for?
    • How do you "simulate" a mouse click that element without actually clicking it?
  9. Write a test suite named "Initial Entries"
    • What are you describe-ing in this test suite?
  10. Write a test that ensures when the loadFeed function is called and completes its work, there is at least a single .entry element within the .feed container
    • How does Jasmine's beforeEach()function work?
    • How does the loadFeed() function in app.js work? Is it synchronous or asynchronous?
  11. Write a test suite named "New Feed Selection"
    • What are you describe-ing in this test suite?
  12. Write a test that ensures when a new feed is loaded by the loadFeed function that the content actually changes
    • How is this test different from the previous test?

Additionally, note that:

  • No test should be dependent on the results of another
  • Callbacks should be used to ensure that feeds are loaded before they are tested
  • Error handling should be implemented for undefined variables and out-of-bound array access
  • When complete, all of your tests should pass

When you're all finished, write a README file detailing all steps required to successfully run the application. If you have added additional tests, provide documentation for what these future features are and what the tests are checking for.

Contributing

This repository is the starter code for all Udacity students. Therefore, we most likely will not accept pull requests.

Archival Note

This repository is deprecated; therefore, we are going to archive it. However, learners will be able to fork it to their personal Github account but cannot submit PRs to this repository. If you have any issues or suggestions to make, feel free to:

frontend-nanodegree-feedreader's People

Contributors

hbkwong avatar hkasemir avatar kratam avatar lucifer1004 avatar matthiasludwig avatar nicolasartman avatar prather-mcs avatar rbudacprojects avatar skh avatar sudkul avatar susansmith avatar thalescomp avatar timbrockman avatar walesmd avatar yhippa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

frontend-nanodegree-feedreader's Issues

Jasmine v2.1.2 vs v2.2

This repo uses Jasmine v2.1.2 but the "JavaScript Testing" course says we should use Jasmine v2.2...

three issues; three pull requests

Thank you Udacity, for teaching me how to use Git and GitHub, and how to fork a project and create a branch off of master when contributing fixes and updates to the codebase.

I used this knowledge to actually contribute two fixes to the Jasmine codebase that were accepted and merged:

There was a bug in Jasmine itself that caused this Udacity project's CSS to break the UI of the Jasmine spec report. I wrote up a description of the bug here, with a reproduction of the bug in a CodePen:

See also my report in the forums where I demonstrate with pictures how the bug breaks the UI on this project:


So I found three things worth fixing in this Udacity project.

1: mis-spelled word:

2: alter your own CSS to keep the bug in Jasmine from affecting the spec report:

(all you have to do is rename the .menu CSS class)

3: If you can see what's wrong and right below...

wrong:

// give callback to $ to let it run only after browser ready:
$(callback());

right:

// give callback to $ to let it run only after browser ready:
$(callback);

...then you will want to stop making the same mistake in this project:

  • /* All of this functionality is heavily reliant upon the DOM, so we
    * place our code in the $() function to ensure it doesn't execute
    * until the DOM is ready.
    */
    $(function() {
    var container = $('.feed'),
    feedList = $('.feed-list'),
    feedItemTemplate = Handlebars.compile($('.tpl-feed-list-item').html()),
    feedId = 0,
    menuIcon = $('.menu-icon-link');
    /* Loop through all of our feeds, assigning an id property to
    * each of the feeds based upon its index within the array.
    * Then parse that feed against the feedItemTemplate (created
    * above using Handlebars) and append it to the list of all
    * available feeds within the menu.
    */
    allFeeds.forEach(function(feed) {
    feed.id = feedId;
    feedList.append(feedItemTemplate(feed));
    feedId++;
    });
    /* When a link in our feedList is clicked on, we want to hide
    * the menu, load the feed, and prevent the default action
    * (following the link) from occuring.
    */
    feedList.on('click', 'a', function() {
    var item = $(this);
    $('body').addClass('menu-hidden');
    loadFeed(item.data('id'));
    return false;
    });
    /* When the menu icon is clicked on, we need to toggle a class
    * on the body to perform the hiding/showing of our menu.
    */
    menuIcon.on('click', function() {
    $('body').toggleClass('menu-hidden');
    });
    }());
  • /* We're placing all of our tests within the $() function,
    * since some of these tests may require DOM elements. We want
    * to ensure they don't run until the DOM is ready.
    */
    $(function() {
    /* This is our first test suite - a test suite just contains
    * a related set of tests. This suite is all about the RSS
    * feeds definitions, the allFeeds variable in our application.
    */
    describe('RSS Feeds', function() {
    /* This is our first test - it tests to make sure that the
    * allFeeds variable has been defined and that it is not
    * empty. Experiment with this before you get started on
    * the rest of this project. What happens when you change
    * allFeeds in app.js to be an empty array and refresh the
    * page?
    */
    it('are defined', function() {
    expect(allFeeds).toBeDefined();
    expect(allFeeds.length).not.toBe(0);
    });
    /* TODO: Write a test that loops through each feed
    * in the allFeeds object and ensures it has a URL defined
    * and that the URL is not empty.
    */
    /* TODO: Write a test that loops through each feed
    * in the allFeeds object and ensures it has a name defined
    * and that the name is not empty.
    */
    });
    /* TODO: Write a new test suite named "The menu" */
    /* TODO: Write a test that ensures the menu element is
    * hidden by default. You'll have to analyze the HTML and
    * the CSS to determine how we're performing the
    * hiding/showing of the menu element.
    */
    /* TODO: Write a test that ensures the menu changes
    * visibility when the menu icon is clicked. This test
    * should have two expectations: does the menu display when
    * clicked and does it hide when clicked again.
    */
    /* TODO: Write a new test suite named "Initial Entries" */
    /* TODO: Write a test that ensures when the loadFeed
    * function is called and completes its work, there is at least
    * a single .entry element within the .feed container.
    * Remember, loadFeed() is asynchronous so this test wil require
    * the use of Jasmine's beforeEach and asynchronous done() function.
    */
    /* TODO: Write a new test suite named "New Feed Selection"
    /* TODO: Write a test that ensures when a new feed is loaded
    * by the loadFeed function that the content actually changes.
    * Remember, loadFeed() is asynchronous.
    */
    }());

I have submitted three pull requests for each of these three things:

1: #8
2: #9
3: #10

Ajax request intermittently fails silently with Server reporting 500 ETIMEDOUT or 500 ESOCKETTIMEDOUT

Jasmine test suite code can intermittently give unexpected results due to the ajax call in js/app.js to https://rsstojson.udacity.com/parseFeed failing silently.

Log of the fail/errors reported by server to client:

Failed to load resource: the server responded with a status of 500 (ETIMEDOUT)
app.js:84 Error in Ajax Request: error - ETIMEDOUT
Failed to load resource: the server responded with a status of 500 (ESOCKETTIMEDOUT)
app.js:84 Error in Ajax Request: error - ESOCKETTIMEDOUT

On checking which requests are failing, it appears to be the request for http://blog.udacity.com/feed.

Failed to load resource: the server responded with a status of 500 (ETIMEDOUT)
app.js:84 Ajax request for http://blog.udacity.com/feed resulted in ERROR: error - ETIMEDOUT
https://rsstojson.udacity.com/parseFeed Failed to load resource: the server responded with a status of 500 (ETIMEDOUT)
app.js:84 Ajax request for http://blog.udacity.com/feed resulted in ERROR: error - ETIMEDOUT
https://rsstojson.udacity.com/parseFeed Failed to load resource: the server responded with a status of 500 (ETIMEDOUT)
app.js:84 Ajax request for http://blog.udacity.com/feed resulted in ERROR: error - ETIMEDOUT
https://rsstojson.udacity.com/parseFeed Failed to load resource: the server responded with a status of 500 (ETIMEDOUT)
app.js:84 Ajax request for http://blog.udacity.com/feed resulted in ERROR: error - ETIMEDOUT
https://rsstojson.udacity.com/parseFeed Failed to load resource: the server responded with a status of 500 (ETIMEDOUT)
app.js:84 Ajax request for http://blog.udacity.com/feed resulted in ERROR: error - ETIMEDOUT

Does the Udacity Blog feed need to be changed to go via feeds.feedburner.com service?

redundant parentheses make jQuery $ .ready function useless

https://github.com/udacity/frontend-nanodegree-feedreader/blob/master/js/app.js#L134
https://github.com/udacity/frontend-nanodegree-feedreader/blob/master/jasmine/spec/feedreader.js#L72

In each of above two lines, there is a pair of parentheses make function expression become an IIFE(Immediately-invoked function expression), which return undefined.

If we want to utilize jQuery's .ready function (https://api.jquery.com/ready/), we should pass a function object to it, not undefined.

I made this PR #17 .

Outdated version of Jasmine

Files need to be updated with Jasmine 3.1.0 or a note for students saying they are using an outdated library

unclosed Todo comment

There's an unclosed Todo Comment on line 66 of feedreader.js. No big deal. I'll make a quick edit and PR.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.