O'Reilly logo

Backbone.js Testing by Ryan Roemer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing and supporting Backbone.js views

Having now created test suites for Backbone.js models and collections, we turn to expanding our test coverage to a Backbone.js view.

The Notes application single note view

The first Backbone.js view we will examine is App.Views.NoteView. This view is responsible for rendering App.Models.Note Markdown data into full HTML as shown in the following screenshot:

The Notes application single note view

View rendered Markdown

The underlying model data for the figure includes the following attributes:

  • title:
    My Title
  • text:
    ## My Heading
    * List item 1
    * List item 2

The text attribute data transforms to HTML as:

<h2 id="myheading">My Heading</h2> <ul> <li>List item ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required