Started adding tests for textbook backbone views
This commit is contained in:
@@ -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
|
||||
|
||||
1
cms/static/coffee/fixtures/textbook-show.underscore
Symbolic link
1
cms/static/coffee/fixtures/textbook-show.underscore
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../templates/js/textbook-show.underscore
|
||||
35
cms/static/coffee/spec/views/textbook_spec.coffee
Normal file
35
cms/static/coffee/spec/views/textbook_spec.coffee
Normal file
@@ -0,0 +1,35 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user