Commit 8227a8c3 by David Baumgold

Started adding tests for textbook backbone views

parent 609c299f
......@@ -242,7 +242,7 @@ PIPELINE_JS = {
) + ['js/hesitate.js', 'js/base.js', 'js/views/feedback.js',
'js/models/section.js', 'js/views/section.js',
'js/models/metadata_model.js', 'js/views/metadata_editor_view.js',
'js/models/textbook.js', 'js/views/textbooks.js',
'js/models/textbook.js', 'js/views/textbook.js',
'js/views/assets.js'],
'output_filename': 'js/cms-application.js',
'test_order': 0
......
../../../templates/js/textbook-show.underscore
\ No newline at end of file
feedbackTpl = readFixtures('system-feedback.underscore')
beforeEach ->
# remove this when we upgrade jasmine-jquery
@addMatchers
toContainText: (text) ->
trimmedText = $.trim(@actual.text())
if text and $.isFunction(text.test)
return text.test(trimmedText)
else
return trimmedText.indexOf(text) != -1;
describe "CMS.Views.TextbookShow", ->
describe "Basic", ->
tpl = readFixtures('textbook-show.underscore')
beforeEach ->
setFixtures($("<script>", {id: "show-textbook-tpl", type: "text/template"}).text(tpl))
appendSetFixtures($("<script>", {id: "system-feedback-tpl", type: "text/template"}).text(feedbackTpl))
appendSetFixtures(sandbox({id: "page-notification"}))
appendSetFixtures(sandbox({id: "page-prompt"}))
@model = new CMS.Models.Textbook({name: "Life Sciences"})
@collection = new CMS.Collections.TextbookSet()
@collection.add(@model)
@view = new CMS.Views.TextbookShow({model: @model})
it "should render properly", ->
@view.render()
expect(@view.$el).toContainText("Life Sciences")
it "should trigger an editOne event on the collection when the edit button is clicked", ->
spyOn(@collection, "trigger").andCallThrough()
@view.render().$(".edit").click()
expect(@collection.trigger).toHaveBeenCalledWith("editOne", @model)
expect(@collection.editing).toEqual(@model)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment