rakeshmithun / Udacity_Jasmine_testing

RMIT project 4 - Feeder reader testing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Udacity - Jasmine UI testing

RMIT project 3 - Feeder reader testing

Objective

This is a project to test a feedReader code in Jasmine.js with jQuery to select DOM elements. I am given a web-based application that reads RSS feeds. The application has incomplete Jasmine test suites, and I write the remaining test suites and get them to pass. The goal is to learn about JavaScript testing, which is an important part of the development process and many organizations practice a standard known as "test-driven development" or TDD.

How to Run the Application

  1. Download or clone this repository.

  2. Find the index.html file, and open the file in a web browser.

  3. The Jasmine tests are displayed at the bottom of the index.html page.

  4. Open the jasmine/spec/feedreader.js file to start editing the test suites.

About the tests

Here are the other test suites written in Jasmine.js by Millie Lin.

Test Suite "The Menu"

By inspecting the menu toggle events in Chrome dev tools, I found the program show and hide the slide menu by toggling class 'menu-hidden' on .

By default, the body should be with class menu-hidden. By using jQuery to select the BODY element and get the class with attr. So that the test should detect if the body tag contains 'menu-hidden' to check if the toggleClass function runs properly.

The click() event is used to check if the 'menu-hidden' class exists to ensure the function goes well.

Test Suite "Initial Entries"

In app.js, it runs loadFeed() to load the data from each feed. If the feed load successfully, it will render the HTML inside the feed container DIV.feed.

Since .entry is an rendered element when feed successfully initialised, by checking if the .feed HTML after loading can see if the entries has been loaded properly.

The loadFeed() is asynchronous so that the test should run beforeEach() and done() to ensure the loadFeed() runs in the test.

By calling loadFeed(0, function(...)) the test load the first feed which contains initial entries for detection.

Test Wuite "New Feed Selection"

There are more than one feed in the allFeeds. The loadFeed() function load specified feed with the id(index).

The second feed content should be different from the first feed. So that by comparing the rendered HTML content, we can check if the program loads a different feed with the function instead the same one.

The HTML can be get in jQuery .html() function.

About

RMIT project 4 - Feeder reader testing


Languages

Language:JavaScript 68.8%Language:HTML 16.5%Language:CSS 14.7%