Use the UI Toolkit's spec helpers.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
require ["jquery", "backbone", "coffee/src/main", "common/js/spec_helpers/ajax_helpers", "jquery.cookie"],
|
||||
require ["jquery", "backbone", "coffee/src/main", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "jquery.cookie"],
|
||||
($, Backbone, main, AjaxHelpers) ->
|
||||
describe "CMS", ->
|
||||
it "should initialize URL", ->
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define ["js/models/section", "common/js/spec_helpers/ajax_helpers", "js/utils/module"], (Section, AjaxHelpers, ModuleUtils) ->
|
||||
define ["js/models/section", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "js/utils/module"], (Section, AjaxHelpers, ModuleUtils) ->
|
||||
describe "Section", ->
|
||||
describe "basic", ->
|
||||
beforeEach ->
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define ["jquery", "common/js/spec_helpers/ajax_helpers", "squire"],
|
||||
define ["jquery", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "squire"],
|
||||
($, AjaxHelpers, Squire) ->
|
||||
|
||||
assetLibraryTpl = readFixtures('asset-library.underscore')
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
define ["js/views/course_info_handout", "js/views/course_info_update", "js/models/module_info", "js/collections/course_update", "common/js/spec_helpers/ajax_helpers"],
|
||||
define ["js/views/course_info_handout", "js/views/course_info_update", "js/models/module_info",
|
||||
"js/collections/course_update", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers"],
|
||||
(CourseInfoHandoutsView, CourseInfoUpdateView, ModuleInfo, CourseUpdateCollection, AjaxHelpers) ->
|
||||
|
||||
describe "Course Updates and Handouts", ->
|
||||
|
||||
@@ -1,339 +1,341 @@
|
||||
define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js/models/course",
|
||||
"js/collections/textbook", "js/views/show_textbook", "js/views/edit_textbook", "js/views/list_textbooks",
|
||||
"js/views/edit_chapter", "common/js/components/views/feedback_prompt",
|
||||
"common/js/components/views/feedback_notification", "common/js/components/utils/view_utils","common/js/spec_helpers/ajax_helpers",
|
||||
"common/js/components/views/feedback_notification", "common/js/components/utils/view_utils",
|
||||
"edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers",
|
||||
"js/spec_helpers/modal_helpers"],
|
||||
(Textbook, Chapter, ChapterSet, Course, TextbookSet, ShowTextbook, EditTextbook, ListTextbooks, EditChapter, Prompt, Notification, ViewUtils, AjaxHelpers, modal_helpers) ->
|
||||
(Textbook, Chapter, ChapterSet, Course, TextbookSet, ShowTextbook, EditTextbook, ListTextbooks, EditChapter,
|
||||
Prompt, Notification, ViewUtils, AjaxHelpers, modal_helpers) ->
|
||||
|
||||
describe "ShowTextbook", ->
|
||||
tpl = readFixtures('show-textbook.underscore')
|
||||
|
||||
beforeEach ->
|
||||
setFixtures($("<script>", {id: "show-textbook-tpl", type: "text/template"}).text(tpl))
|
||||
appendSetFixtures(sandbox({id: "page-notification"}))
|
||||
appendSetFixtures(sandbox({id: "page-prompt"}))
|
||||
@model = new Textbook({name: "Life Sciences", id: "0life-sciences"})
|
||||
spyOn(@model, "destroy").and.callThrough()
|
||||
@collection = new TextbookSet([@model])
|
||||
@view = new ShowTextbook({model: @model})
|
||||
|
||||
@promptSpies = jasmine.stealth.spyOnConstructor(Prompt, "Warning", ["show", "hide"])
|
||||
@promptSpies.show.and.returnValue(@promptSpies)
|
||||
window.course = new Course({
|
||||
id: "5",
|
||||
name: "Course Name",
|
||||
url_name: "course_name",
|
||||
org: "course_org",
|
||||
num: "course_num",
|
||||
revision: "course_rev"
|
||||
});
|
||||
|
||||
afterEach ->
|
||||
delete window.course
|
||||
|
||||
describe "Basic", ->
|
||||
it "should render properly", ->
|
||||
@view.render()
|
||||
expect(@view.$el).toContainText("Life Sciences")
|
||||
|
||||
it "should set the 'editing' property on the model when the edit button is clicked", ->
|
||||
@view.render().$(".edit").click()
|
||||
expect(@model.get("editing")).toBeTruthy()
|
||||
|
||||
it "should pop a delete confirmation when the delete button is clicked", ->
|
||||
@view.render().$(".delete").click()
|
||||
expect(@promptSpies.constructor).toHaveBeenCalled()
|
||||
ctorOptions = @promptSpies.constructor.calls.mostRecent().args[0]
|
||||
expect(ctorOptions.title).toMatch(/Life Sciences/)
|
||||
# hasn't actually been removed
|
||||
expect(@model.destroy).not.toHaveBeenCalled()
|
||||
expect(@collection).toContain(@model)
|
||||
|
||||
it "should show chapters appropriately", ->
|
||||
@model.get("chapters").add([{}, {}, {}])
|
||||
@model.set('showChapters', false)
|
||||
@view.render().$(".show-chapters").click()
|
||||
expect(@model.get('showChapters')).toBeTruthy()
|
||||
|
||||
it "should hide chapters appropriately", ->
|
||||
@model.get("chapters").add([{}, {}, {}])
|
||||
@model.set('showChapters', true)
|
||||
@view.render().$(".hide-chapters").click()
|
||||
expect(@model.get('showChapters')).toBeFalsy()
|
||||
|
||||
describe "AJAX", ->
|
||||
beforeEach ->
|
||||
@savingSpies = jasmine.stealth.spyOnConstructor(Notification, "Mini",
|
||||
["show", "hide"])
|
||||
@savingSpies.show.and.returnValue(@savingSpies)
|
||||
CMS.URL.TEXTBOOKS = "/textbooks"
|
||||
|
||||
afterEach ->
|
||||
delete CMS.URL.TEXTBOOKS
|
||||
|
||||
it "should destroy itself on confirmation", ->
|
||||
requests = AjaxHelpers["requests"](this)
|
||||
|
||||
@view.render().$(".delete").click()
|
||||
ctorOptions = @promptSpies.constructor.calls.mostRecent().args[0]
|
||||
# run the primary function to indicate confirmation
|
||||
ctorOptions.actions.primary.click(@promptSpies)
|
||||
# AJAX request has been sent, but not yet returned
|
||||
expect(@model.destroy).toHaveBeenCalled()
|
||||
expect(requests.length).toEqual(1)
|
||||
expect(@savingSpies.constructor).toHaveBeenCalled()
|
||||
expect(@savingSpies.show).toHaveBeenCalled()
|
||||
expect(@savingSpies.hide).not.toHaveBeenCalled()
|
||||
savingOptions = @savingSpies.constructor.calls.mostRecent().args[0]
|
||||
expect(savingOptions.title).toMatch(/Deleting/)
|
||||
# return a success response
|
||||
requests[0].respond(204)
|
||||
expect(@savingSpies.hide).toHaveBeenCalled()
|
||||
expect(@collection.contains(@model)).toBeFalsy()
|
||||
|
||||
describe "EditTextbook", ->
|
||||
describe "Basic", ->
|
||||
tpl = readFixtures('edit-textbook.underscore')
|
||||
describe "ShowTextbook", ->
|
||||
tpl = readFixtures('show-textbook.underscore')
|
||||
|
||||
beforeEach ->
|
||||
setFixtures($("<script>", {id: "edit-textbook-tpl", type: "text/template"}).text(tpl))
|
||||
setFixtures($("<script>", {id: "show-textbook-tpl", type: "text/template"}).text(tpl))
|
||||
appendSetFixtures(sandbox({id: "page-notification"}))
|
||||
appendSetFixtures(sandbox({id: "page-prompt"}))
|
||||
@model = new Textbook({name: "Life Sciences", editing: true})
|
||||
spyOn(@model, 'save')
|
||||
@collection = new TextbookSet()
|
||||
@collection.add(@model)
|
||||
@view = new EditTextbook({model: @model})
|
||||
spyOn(@view, 'render').and.callThrough()
|
||||
@model = new Textbook({name: "Life Sciences", id: "0life-sciences"})
|
||||
spyOn(@model, "destroy").and.callThrough()
|
||||
@collection = new TextbookSet([@model])
|
||||
@view = new ShowTextbook({model: @model})
|
||||
|
||||
it "should render properly", ->
|
||||
@promptSpies = jasmine.stealth.spyOnConstructor(Prompt, "Warning", ["show", "hide"])
|
||||
@promptSpies.show.and.returnValue(@promptSpies)
|
||||
window.course = new Course({
|
||||
id: "5",
|
||||
name: "Course Name",
|
||||
url_name: "course_name",
|
||||
org: "course_org",
|
||||
num: "course_num",
|
||||
revision: "course_rev"
|
||||
});
|
||||
|
||||
afterEach ->
|
||||
delete window.course
|
||||
|
||||
describe "Basic", ->
|
||||
it "should render properly", ->
|
||||
@view.render()
|
||||
expect(@view.$el).toContainText("Life Sciences")
|
||||
|
||||
it "should set the 'editing' property on the model when the edit button is clicked", ->
|
||||
@view.render().$(".edit").click()
|
||||
expect(@model.get("editing")).toBeTruthy()
|
||||
|
||||
it "should pop a delete confirmation when the delete button is clicked", ->
|
||||
@view.render().$(".delete").click()
|
||||
expect(@promptSpies.constructor).toHaveBeenCalled()
|
||||
ctorOptions = @promptSpies.constructor.calls.mostRecent().args[0]
|
||||
expect(ctorOptions.title).toMatch(/Life Sciences/)
|
||||
# hasn't actually been removed
|
||||
expect(@model.destroy).not.toHaveBeenCalled()
|
||||
expect(@collection).toContain(@model)
|
||||
|
||||
it "should show chapters appropriately", ->
|
||||
@model.get("chapters").add([{}, {}, {}])
|
||||
@model.set('showChapters', false)
|
||||
@view.render().$(".show-chapters").click()
|
||||
expect(@model.get('showChapters')).toBeTruthy()
|
||||
|
||||
it "should hide chapters appropriately", ->
|
||||
@model.get("chapters").add([{}, {}, {}])
|
||||
@model.set('showChapters', true)
|
||||
@view.render().$(".hide-chapters").click()
|
||||
expect(@model.get('showChapters')).toBeFalsy()
|
||||
|
||||
describe "AJAX", ->
|
||||
beforeEach ->
|
||||
@savingSpies = jasmine.stealth.spyOnConstructor(Notification, "Mini",
|
||||
["show", "hide"])
|
||||
@savingSpies.show.and.returnValue(@savingSpies)
|
||||
CMS.URL.TEXTBOOKS = "/textbooks"
|
||||
|
||||
afterEach ->
|
||||
delete CMS.URL.TEXTBOOKS
|
||||
|
||||
it "should destroy itself on confirmation", ->
|
||||
requests = AjaxHelpers["requests"](this)
|
||||
|
||||
@view.render().$(".delete").click()
|
||||
ctorOptions = @promptSpies.constructor.calls.mostRecent().args[0]
|
||||
# run the primary function to indicate confirmation
|
||||
ctorOptions.actions.primary.click(@promptSpies)
|
||||
# AJAX request has been sent, but not yet returned
|
||||
expect(@model.destroy).toHaveBeenCalled()
|
||||
expect(requests.length).toEqual(1)
|
||||
expect(@savingSpies.constructor).toHaveBeenCalled()
|
||||
expect(@savingSpies.show).toHaveBeenCalled()
|
||||
expect(@savingSpies.hide).not.toHaveBeenCalled()
|
||||
savingOptions = @savingSpies.constructor.calls.mostRecent().args[0]
|
||||
expect(savingOptions.title).toMatch(/Deleting/)
|
||||
# return a success response
|
||||
requests[0].respond(204)
|
||||
expect(@savingSpies.hide).toHaveBeenCalled()
|
||||
expect(@collection.contains(@model)).toBeFalsy()
|
||||
|
||||
describe "EditTextbook", ->
|
||||
describe "Basic", ->
|
||||
tpl = readFixtures('edit-textbook.underscore')
|
||||
|
||||
beforeEach ->
|
||||
setFixtures($("<script>", {id: "edit-textbook-tpl", type: "text/template"}).text(tpl))
|
||||
appendSetFixtures(sandbox({id: "page-notification"}))
|
||||
appendSetFixtures(sandbox({id: "page-prompt"}))
|
||||
@model = new Textbook({name: "Life Sciences", editing: true})
|
||||
spyOn(@model, 'save')
|
||||
@collection = new TextbookSet()
|
||||
@collection.add(@model)
|
||||
@view = new EditTextbook({model: @model})
|
||||
spyOn(@view, 'render').and.callThrough()
|
||||
|
||||
it "should render properly", ->
|
||||
@view.render()
|
||||
expect(@view.$("input[name=textbook-name]").val()).toEqual("Life Sciences")
|
||||
|
||||
it "should allow you to create new empty chapters", ->
|
||||
@view.render()
|
||||
numChapters = @model.get("chapters").length
|
||||
@view.$(".action-add-chapter").click()
|
||||
expect(@model.get("chapters").length).toEqual(numChapters+1)
|
||||
expect(@model.get("chapters").last().isEmpty()).toBeTruthy()
|
||||
|
||||
it "should save properly", ->
|
||||
@view.render()
|
||||
@view.$("input[name=textbook-name]").val("starfish")
|
||||
@view.$("input[name=chapter1-name]").val("wallflower")
|
||||
@view.$("input[name=chapter1-asset-path]").val("foobar")
|
||||
@view.$("form").submit()
|
||||
expect(@model.get("name")).toEqual("starfish")
|
||||
chapter = @model.get("chapters").first()
|
||||
expect(chapter.get("name")).toEqual("wallflower")
|
||||
expect(chapter.get("asset_path")).toEqual("foobar")
|
||||
expect(@model.save).toHaveBeenCalled()
|
||||
|
||||
it "should not save on invalid", ->
|
||||
@view.render()
|
||||
@view.$("input[name=textbook-name]").val("")
|
||||
@view.$("input[name=chapter1-asset-path]").val("foobar.pdf")
|
||||
@view.$("form").submit()
|
||||
expect(@model.validationError).toBeTruthy()
|
||||
expect(@model.save).not.toHaveBeenCalled()
|
||||
|
||||
it "does not save on cancel", ->
|
||||
@model.get("chapters").add([{name: "a", asset_path: "b"}])
|
||||
@view.render()
|
||||
@view.$("input[name=textbook-name]").val("starfish")
|
||||
@view.$("input[name=chapter1-asset-path]").val("foobar.pdf")
|
||||
@view.$(".action-cancel").click()
|
||||
expect(@model.get("name")).not.toEqual("starfish")
|
||||
chapter = @model.get("chapters").first()
|
||||
expect(chapter.get("asset_path")).not.toEqual("foobar")
|
||||
expect(@model.save).not.toHaveBeenCalled()
|
||||
|
||||
it "should be possible to correct validation errors", ->
|
||||
@view.render()
|
||||
@view.$("input[name=textbook-name]").val("")
|
||||
@view.$("input[name=chapter1-asset-path]").val("foobar.pdf")
|
||||
@view.$("form").submit()
|
||||
expect(@model.validationError).toBeTruthy()
|
||||
expect(@model.save).not.toHaveBeenCalled()
|
||||
@view.$("input[name=textbook-name]").val("starfish")
|
||||
@view.$("input[name=chapter1-name]").val("foobar")
|
||||
@view.$("form").submit()
|
||||
expect(@model.validationError).toBeFalsy()
|
||||
expect(@model.save).toHaveBeenCalled()
|
||||
|
||||
it "removes all empty chapters on cancel if the model has a non-empty chapter", ->
|
||||
chapters = @model.get("chapters")
|
||||
chapters.at(0).set("name", "non-empty")
|
||||
@model.setOriginalAttributes()
|
||||
@view.render()
|
||||
chapters.add([{}, {}, {}]) # add three empty chapters
|
||||
expect(chapters.length).toEqual(4)
|
||||
@view.$(".action-cancel").click()
|
||||
expect(chapters.length).toEqual(1)
|
||||
expect(chapters.first().get('name')).toEqual("non-empty")
|
||||
|
||||
it "removes all empty chapters on cancel except one if the model has no non-empty chapters", ->
|
||||
chapters = @model.get("chapters")
|
||||
@view.render()
|
||||
chapters.add([{}, {}, {}]) # add three empty chapters
|
||||
expect(chapters.length).toEqual(4)
|
||||
@view.$(".action-cancel").click()
|
||||
expect(chapters.length).toEqual(1)
|
||||
|
||||
describe "ListTextbooks", ->
|
||||
noTextbooksTpl = readFixtures("no-textbooks.underscore")
|
||||
editTextbooktpl = readFixtures('edit-textbook.underscore')
|
||||
|
||||
beforeEach ->
|
||||
appendSetFixtures($("<script>", {id: "no-textbooks-tpl", type: "text/template"}).text(noTextbooksTpl))
|
||||
appendSetFixtures($("<script>", {id: "edit-textbook-tpl", type: "text/template"}).text(editTextbooktpl))
|
||||
@collection = new TextbookSet
|
||||
@view = new ListTextbooks({collection: @collection})
|
||||
@view.render()
|
||||
expect(@view.$("input[name=textbook-name]").val()).toEqual("Life Sciences")
|
||||
|
||||
it "should allow you to create new empty chapters", ->
|
||||
@view.render()
|
||||
numChapters = @model.get("chapters").length
|
||||
@view.$(".action-add-chapter").click()
|
||||
expect(@model.get("chapters").length).toEqual(numChapters+1)
|
||||
expect(@model.get("chapters").last().isEmpty()).toBeTruthy()
|
||||
it "should scroll to newly added textbook", ->
|
||||
spyOn(ViewUtils, 'setScrollOffset')
|
||||
@view.$(".new-button").click()
|
||||
$sectionEl = @view.$el.find('section:last')
|
||||
expect($sectionEl.length).toEqual(1)
|
||||
expect(ViewUtils.setScrollOffset).toHaveBeenCalledWith($sectionEl, 0)
|
||||
|
||||
it "should save properly", ->
|
||||
@view.render()
|
||||
@view.$("input[name=textbook-name]").val("starfish")
|
||||
@view.$("input[name=chapter1-name]").val("wallflower")
|
||||
@view.$("input[name=chapter1-asset-path]").val("foobar")
|
||||
@view.$("form").submit()
|
||||
expect(@model.get("name")).toEqual("starfish")
|
||||
chapter = @model.get("chapters").first()
|
||||
expect(chapter.get("name")).toEqual("wallflower")
|
||||
expect(chapter.get("asset_path")).toEqual("foobar")
|
||||
expect(@model.save).toHaveBeenCalled()
|
||||
|
||||
it "should not save on invalid", ->
|
||||
@view.render()
|
||||
@view.$("input[name=textbook-name]").val("")
|
||||
@view.$("input[name=chapter1-asset-path]").val("foobar.pdf")
|
||||
@view.$("form").submit()
|
||||
expect(@model.validationError).toBeTruthy()
|
||||
expect(@model.save).not.toHaveBeenCalled()
|
||||
|
||||
it "does not save on cancel", ->
|
||||
@model.get("chapters").add([{name: "a", asset_path: "b"}])
|
||||
@view.render()
|
||||
@view.$("input[name=textbook-name]").val("starfish")
|
||||
@view.$("input[name=chapter1-asset-path]").val("foobar.pdf")
|
||||
@view.$(".action-cancel").click()
|
||||
expect(@model.get("name")).not.toEqual("starfish")
|
||||
chapter = @model.get("chapters").first()
|
||||
expect(chapter.get("asset_path")).not.toEqual("foobar")
|
||||
expect(@model.save).not.toHaveBeenCalled()
|
||||
|
||||
it "should be possible to correct validation errors", ->
|
||||
@view.render()
|
||||
@view.$("input[name=textbook-name]").val("")
|
||||
@view.$("input[name=chapter1-asset-path]").val("foobar.pdf")
|
||||
@view.$("form").submit()
|
||||
expect(@model.validationError).toBeTruthy()
|
||||
expect(@model.save).not.toHaveBeenCalled()
|
||||
@view.$("input[name=textbook-name]").val("starfish")
|
||||
@view.$("input[name=chapter1-name]").val("foobar")
|
||||
@view.$("form").submit()
|
||||
expect(@model.validationError).toBeFalsy()
|
||||
expect(@model.save).toHaveBeenCalled()
|
||||
|
||||
it "removes all empty chapters on cancel if the model has a non-empty chapter", ->
|
||||
chapters = @model.get("chapters")
|
||||
chapters.at(0).set("name", "non-empty")
|
||||
@model.setOriginalAttributes()
|
||||
@view.render()
|
||||
chapters.add([{}, {}, {}]) # add three empty chapters
|
||||
expect(chapters.length).toEqual(4)
|
||||
@view.$(".action-cancel").click()
|
||||
expect(chapters.length).toEqual(1)
|
||||
expect(chapters.first().get('name')).toEqual("non-empty")
|
||||
|
||||
it "removes all empty chapters on cancel except one if the model has no non-empty chapters", ->
|
||||
chapters = @model.get("chapters")
|
||||
@view.render()
|
||||
chapters.add([{}, {}, {}]) # add three empty chapters
|
||||
expect(chapters.length).toEqual(4)
|
||||
@view.$(".action-cancel").click()
|
||||
expect(chapters.length).toEqual(1)
|
||||
|
||||
describe "ListTextbooks", ->
|
||||
noTextbooksTpl = readFixtures("no-textbooks.underscore")
|
||||
editTextbooktpl = readFixtures('edit-textbook.underscore')
|
||||
|
||||
beforeEach ->
|
||||
appendSetFixtures($("<script>", {id: "no-textbooks-tpl", type: "text/template"}).text(noTextbooksTpl))
|
||||
appendSetFixtures($("<script>", {id: "edit-textbook-tpl", type: "text/template"}).text(editTextbooktpl))
|
||||
@collection = new TextbookSet
|
||||
@view = new ListTextbooks({collection: @collection})
|
||||
@view.render()
|
||||
|
||||
it "should scroll to newly added textbook", ->
|
||||
spyOn(ViewUtils, 'setScrollOffset')
|
||||
@view.$(".new-button").click()
|
||||
$sectionEl = @view.$el.find('section:last')
|
||||
expect($sectionEl.length).toEqual(1)
|
||||
expect(ViewUtils.setScrollOffset).toHaveBeenCalledWith($sectionEl, 0)
|
||||
|
||||
it "should focus first input element of newly added textbook", ->
|
||||
spyOn(jQuery.fn, 'focus').and.callThrough()
|
||||
jasmine.addMatchers
|
||||
toHaveBeenCalledOnJQueryObject: () ->
|
||||
return {
|
||||
compare: (actual, expected) ->
|
||||
return {
|
||||
pass: actual.calls && actual.calls.mostRecent() &&
|
||||
actual.calls.mostRecent().object[0] == expected[0]
|
||||
}
|
||||
it "should focus first input element of newly added textbook", ->
|
||||
spyOn(jQuery.fn, 'focus').and.callThrough()
|
||||
jasmine.addMatchers
|
||||
toHaveBeenCalledOnJQueryObject: () ->
|
||||
return {
|
||||
compare: (actual, expected) ->
|
||||
return {
|
||||
pass: actual.calls && actual.calls.mostRecent() &&
|
||||
actual.calls.mostRecent().object[0] == expected[0]
|
||||
}
|
||||
}
|
||||
@view.$(".new-button").click()
|
||||
$inputEl = @view.$el.find('section:last input:first')
|
||||
expect($inputEl.length).toEqual(1)
|
||||
# testing for element focused seems to be tricky
|
||||
# (see http://stackoverflow.com/questions/967096)
|
||||
# and the following doesn't seem to work
|
||||
# expect($inputEl).toBeFocused()
|
||||
# expect($inputEl.find(':focus').length).toEqual(1)
|
||||
expect(jQuery.fn.focus).toHaveBeenCalledOnJQueryObject($inputEl)
|
||||
@view.$(".new-button").click()
|
||||
$inputEl = @view.$el.find('section:last input:first')
|
||||
expect($inputEl.length).toEqual(1)
|
||||
# testing for element focused seems to be tricky
|
||||
# (see http://stackoverflow.com/questions/967096)
|
||||
# and the following doesn't seem to work
|
||||
# expect($inputEl).toBeFocused()
|
||||
# expect($inputEl.find(':focus').length).toEqual(1)
|
||||
expect(jQuery.fn.focus).toHaveBeenCalledOnJQueryObject($inputEl)
|
||||
|
||||
# describe "ListTextbooks", ->
|
||||
# noTextbooksTpl = readFixtures("no-textbooks.underscore")
|
||||
#
|
||||
# beforeEach ->
|
||||
# setFixtures($("<script>", {id: "no-textbooks-tpl", type: "text/template"}).text(noTextbooksTpl))
|
||||
# @showSpies = spyOnConstructor("ShowTextbook", ["render"])
|
||||
# @showSpies.render.and.returnValue(@showSpies) # equivalent of `return this`
|
||||
# showEl = $("<li>")
|
||||
# @showSpies.$el = showEl
|
||||
# @showSpies.el = showEl.get(0)
|
||||
# @editSpies = spyOnConstructor("EditTextbook", ["render"])
|
||||
# editEl = $("<li>")
|
||||
# @editSpies.render.and.returnValue(@editSpies)
|
||||
# @editSpies.$el = editEl
|
||||
# @editSpies.el= editEl.get(0)
|
||||
#
|
||||
# @collection = new TextbookSet
|
||||
# @view = new ListTextbooks({collection: @collection})
|
||||
# @view.render()
|
||||
#
|
||||
# it "should render the empty template if there are no textbooks", ->
|
||||
# expect(@view.$el).toContainText("You haven't added any textbooks to this course yet")
|
||||
# expect(@view.$el).toContain(".new-button")
|
||||
# expect(@showSpies.constructor).not.toHaveBeenCalled()
|
||||
# expect(@editSpies.constructor).not.toHaveBeenCalled()
|
||||
#
|
||||
# it "should render ShowTextbook views by default if no textbook is being edited", ->
|
||||
# # add three empty textbooks to the collection
|
||||
# @collection.add([{}, {}, {}])
|
||||
# # reset spies due to re-rendering on collection modification
|
||||
# @showSpies.constructor.reset()
|
||||
# @editSpies.constructor.reset()
|
||||
# # render once and test
|
||||
# @view.render()
|
||||
#
|
||||
# expect(@view.$el).not.toContainText(
|
||||
# "You haven't added any textbooks to this course yet")
|
||||
# expect(@showSpies.constructor).toHaveBeenCalled()
|
||||
# expect(@showSpies.constructor.calls.length).toEqual(3);
|
||||
# expect(@editSpies.constructor).not.toHaveBeenCalled()
|
||||
#
|
||||
# it "should render an EditTextbook view for a textbook being edited", ->
|
||||
# # add three empty textbooks to the collection: the first and third
|
||||
# # should be shown, and the second should be edited
|
||||
# @collection.add([{editing: false}, {editing: true}, {editing: false}])
|
||||
# editing = @collection.at(1)
|
||||
# expect(editing.get("editing")).toBeTruthy()
|
||||
# # reset spies
|
||||
# @showSpies.constructor.reset()
|
||||
# @editSpies.constructor.reset()
|
||||
# # render once and test
|
||||
# @view.render()
|
||||
#
|
||||
# expect(@showSpies.constructor).toHaveBeenCalled()
|
||||
# expect(@showSpies.constructor.calls.length).toEqual(2)
|
||||
# expect(@showSpies.constructor).not.toHaveBeenCalledWith({model: editing})
|
||||
# expect(@editSpies.constructor).toHaveBeenCalled()
|
||||
# expect(@editSpies.constructor.calls.length).toEqual(1)
|
||||
# expect(@editSpies.constructor).toHaveBeenCalledWith({model: editing})
|
||||
#
|
||||
# it "should add a new textbook when the new-button is clicked", ->
|
||||
# # reset spies
|
||||
# @showSpies.constructor.reset()
|
||||
# @editSpies.constructor.reset()
|
||||
# # test
|
||||
# @view.$(".new-button").click()
|
||||
#
|
||||
# expect(@collection.length).toEqual(1)
|
||||
# expect(@view.$el).toContain(@editSpies.$el)
|
||||
# expect(@view.$el).not.toContain(@showSpies.$el)
|
||||
# describe "ListTextbooks", ->
|
||||
# noTextbooksTpl = readFixtures("no-textbooks.underscore")
|
||||
#
|
||||
# beforeEach ->
|
||||
# setFixtures($("<script>", {id: "no-textbooks-tpl", type: "text/template"}).text(noTextbooksTpl))
|
||||
# @showSpies = spyOnConstructor("ShowTextbook", ["render"])
|
||||
# @showSpies.render.and.returnValue(@showSpies) # equivalent of `return this`
|
||||
# showEl = $("<li>")
|
||||
# @showSpies.$el = showEl
|
||||
# @showSpies.el = showEl.get(0)
|
||||
# @editSpies = spyOnConstructor("EditTextbook", ["render"])
|
||||
# editEl = $("<li>")
|
||||
# @editSpies.render.and.returnValue(@editSpies)
|
||||
# @editSpies.$el = editEl
|
||||
# @editSpies.el= editEl.get(0)
|
||||
#
|
||||
# @collection = new TextbookSet
|
||||
# @view = new ListTextbooks({collection: @collection})
|
||||
# @view.render()
|
||||
#
|
||||
# it "should render the empty template if there are no textbooks", ->
|
||||
# expect(@view.$el).toContainText("You haven't added any textbooks to this course yet")
|
||||
# expect(@view.$el).toContain(".new-button")
|
||||
# expect(@showSpies.constructor).not.toHaveBeenCalled()
|
||||
# expect(@editSpies.constructor).not.toHaveBeenCalled()
|
||||
#
|
||||
# it "should render ShowTextbook views by default if no textbook is being edited", ->
|
||||
# # add three empty textbooks to the collection
|
||||
# @collection.add([{}, {}, {}])
|
||||
# # reset spies due to re-rendering on collection modification
|
||||
# @showSpies.constructor.reset()
|
||||
# @editSpies.constructor.reset()
|
||||
# # render once and test
|
||||
# @view.render()
|
||||
#
|
||||
# expect(@view.$el).not.toContainText(
|
||||
# "You haven't added any textbooks to this course yet")
|
||||
# expect(@showSpies.constructor).toHaveBeenCalled()
|
||||
# expect(@showSpies.constructor.calls.length).toEqual(3);
|
||||
# expect(@editSpies.constructor).not.toHaveBeenCalled()
|
||||
#
|
||||
# it "should render an EditTextbook view for a textbook being edited", ->
|
||||
# # add three empty textbooks to the collection: the first and third
|
||||
# # should be shown, and the second should be edited
|
||||
# @collection.add([{editing: false}, {editing: true}, {editing: false}])
|
||||
# editing = @collection.at(1)
|
||||
# expect(editing.get("editing")).toBeTruthy()
|
||||
# # reset spies
|
||||
# @showSpies.constructor.reset()
|
||||
# @editSpies.constructor.reset()
|
||||
# # render once and test
|
||||
# @view.render()
|
||||
#
|
||||
# expect(@showSpies.constructor).toHaveBeenCalled()
|
||||
# expect(@showSpies.constructor.calls.length).toEqual(2)
|
||||
# expect(@showSpies.constructor).not.toHaveBeenCalledWith({model: editing})
|
||||
# expect(@editSpies.constructor).toHaveBeenCalled()
|
||||
# expect(@editSpies.constructor.calls.length).toEqual(1)
|
||||
# expect(@editSpies.constructor).toHaveBeenCalledWith({model: editing})
|
||||
#
|
||||
# it "should add a new textbook when the new-button is clicked", ->
|
||||
# # reset spies
|
||||
# @showSpies.constructor.reset()
|
||||
# @editSpies.constructor.reset()
|
||||
# # test
|
||||
# @view.$(".new-button").click()
|
||||
#
|
||||
# expect(@collection.length).toEqual(1)
|
||||
# expect(@view.$el).toContain(@editSpies.$el)
|
||||
# expect(@view.$el).not.toContain(@showSpies.$el)
|
||||
|
||||
|
||||
describe "EditChapter", ->
|
||||
beforeEach ->
|
||||
modal_helpers.installModalTemplates()
|
||||
@model = new Chapter
|
||||
name: "Chapter 1"
|
||||
asset_path: "/ch1.pdf"
|
||||
@collection = new ChapterSet()
|
||||
@collection.add(@model)
|
||||
@view = new EditChapter({model: @model})
|
||||
spyOn(@view, "remove").and.callThrough()
|
||||
CMS.URL.UPLOAD_ASSET = "/upload"
|
||||
window.course = new Course({name: "abcde"})
|
||||
describe "EditChapter", ->
|
||||
beforeEach ->
|
||||
modal_helpers.installModalTemplates()
|
||||
@model = new Chapter
|
||||
name: "Chapter 1"
|
||||
asset_path: "/ch1.pdf"
|
||||
@collection = new ChapterSet()
|
||||
@collection.add(@model)
|
||||
@view = new EditChapter({model: @model})
|
||||
spyOn(@view, "remove").and.callThrough()
|
||||
CMS.URL.UPLOAD_ASSET = "/upload"
|
||||
window.course = new Course({name: "abcde"})
|
||||
|
||||
afterEach ->
|
||||
delete CMS.URL.UPLOAD_ASSET
|
||||
delete window.course
|
||||
afterEach ->
|
||||
delete CMS.URL.UPLOAD_ASSET
|
||||
delete window.course
|
||||
|
||||
it "can render", ->
|
||||
@view.render()
|
||||
expect(@view.$("input.chapter-name").val()).toEqual("Chapter 1")
|
||||
expect(@view.$("input.chapter-asset-path").val()).toEqual("/ch1.pdf")
|
||||
it "can render", ->
|
||||
@view.render()
|
||||
expect(@view.$("input.chapter-name").val()).toEqual("Chapter 1")
|
||||
expect(@view.$("input.chapter-asset-path").val()).toEqual("/ch1.pdf")
|
||||
|
||||
it "can delete itself", ->
|
||||
@view.render().$(".action-close").click()
|
||||
expect(@collection.length).toEqual(0)
|
||||
expect(@view.remove).toHaveBeenCalled()
|
||||
it "can delete itself", ->
|
||||
@view.render().$(".action-close").click()
|
||||
expect(@collection.length).toEqual(0)
|
||||
expect(@view.remove).toHaveBeenCalled()
|
||||
|
||||
# it "can open an upload dialog", ->
|
||||
# uploadSpies = spyOnConstructor("UploadDialog", ["show", "el"])
|
||||
# uploadSpies.show.and.returnValue(uploadSpies)
|
||||
#
|
||||
# @view.render().$(".action-upload").click()
|
||||
# ctorOptions = uploadSpies.constructor.calls.mostRecent().args[0]
|
||||
# expect(ctorOptions.model.get('title')).toMatch(/abcde/)
|
||||
# expect(typeof ctorOptions.onSuccess).toBe('function')
|
||||
# expect(uploadSpies.show).toHaveBeenCalled()
|
||||
# it "can open an upload dialog", ->
|
||||
# uploadSpies = spyOnConstructor("UploadDialog", ["show", "el"])
|
||||
# uploadSpies.show.and.returnValue(uploadSpies)
|
||||
#
|
||||
# @view.render().$(".action-upload").click()
|
||||
# ctorOptions = uploadSpies.constructor.calls.mostRecent().args[0]
|
||||
# expect(ctorOptions.model.get('title')).toMatch(/abcde/)
|
||||
# expect(typeof ctorOptions.onSuccess).toBe('function')
|
||||
# expect(uploadSpies.show).toHaveBeenCalled()
|
||||
|
||||
# Disabling because this test does not close the modal dialog. This can cause
|
||||
# tests that run after it to fail (see STUD-1963).
|
||||
xit "saves content when opening upload dialog", ->
|
||||
@view.render()
|
||||
@view.$("input.chapter-name").val("rainbows")
|
||||
@view.$("input.chapter-asset-path").val("unicorns")
|
||||
@view.$(".action-upload").click()
|
||||
expect(@model.get("name")).toEqual("rainbows")
|
||||
expect(@model.get("asset_path")).toEqual("unicorns")
|
||||
# Disabling because this test does not close the modal dialog. This can cause
|
||||
# tests that run after it to fail (see STUD-1963).
|
||||
xit "saves content when opening upload dialog", ->
|
||||
@view.render()
|
||||
@view.$("input.chapter-name").val("rainbows")
|
||||
@view.$("input.chapter-asset-path").val("unicorns")
|
||||
@view.$(".action-upload").click()
|
||||
expect(@model.get("name")).toEqual("rainbows")
|
||||
expect(@model.get("asset_path")).toEqual("unicorns")
|
||||
|
||||
@@ -1,133 +1,135 @@
|
||||
define ["js/models/uploads", "js/views/uploads", "js/models/chapter", "common/js/spec_helpers/ajax_helpers", "js/spec_helpers/modal_helpers"], (FileUpload, UploadDialog, Chapter, AjaxHelpers, modal_helpers) ->
|
||||
define ["js/models/uploads", "js/views/uploads", "js/models/chapter",
|
||||
"edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "js/spec_helpers/modal_helpers"],
|
||||
(FileUpload, UploadDialog, Chapter, AjaxHelpers, modal_helpers) ->
|
||||
|
||||
describe "UploadDialog", ->
|
||||
tpl = readFixtures("upload-dialog.underscore")
|
||||
describe "UploadDialog", ->
|
||||
tpl = readFixtures("upload-dialog.underscore")
|
||||
|
||||
beforeEach ->
|
||||
modal_helpers.installModalTemplates()
|
||||
appendSetFixtures($("<script>", {id: "upload-dialog-tpl", type: "text/template"}).text(tpl))
|
||||
CMS.URL.UPLOAD_ASSET = "/upload"
|
||||
@model = new FileUpload(
|
||||
mimeTypes: ['application/pdf']
|
||||
)
|
||||
@dialogResponse = dialogResponse = []
|
||||
@mockFiles = []
|
||||
|
||||
afterEach ->
|
||||
delete CMS.URL.UPLOAD_ASSET
|
||||
modal_helpers.cancelModalIfShowing()
|
||||
|
||||
createTestView = (test) ->
|
||||
view = new UploadDialog(
|
||||
model: test.model,
|
||||
url: CMS.URL.UPLOAD_ASSET,
|
||||
onSuccess: (response) =>
|
||||
test.dialogResponse.push(response.response)
|
||||
)
|
||||
spyOn(view, 'remove').and.callThrough()
|
||||
|
||||
# create mock file input, so that we aren't subject to browser restrictions
|
||||
mockFileInput = jasmine.createSpy('mockFileInput')
|
||||
mockFileInput.files = test.mockFiles
|
||||
jqMockFileInput = jasmine.createSpyObj('jqMockFileInput', ['get', 'replaceWith'])
|
||||
jqMockFileInput.get.and.returnValue(mockFileInput)
|
||||
originalView$ = view.$
|
||||
spyOn(view, "$").and.callFake (selector) ->
|
||||
if selector == "input[type=file]"
|
||||
jqMockFileInput
|
||||
else
|
||||
originalView$.apply(this, arguments)
|
||||
@lastView = view
|
||||
|
||||
describe "Basic", ->
|
||||
it "should render without a file selected", ->
|
||||
view = createTestView(this)
|
||||
view.render()
|
||||
expect(view.$el).toContainElement("input[type=file]")
|
||||
expect(view.$(".action-upload")).toHaveClass("disabled")
|
||||
|
||||
it "should render with a PDF selected", ->
|
||||
view = createTestView(this)
|
||||
file = {name: "fake.pdf", "type": "application/pdf"}
|
||||
@mockFiles.push(file)
|
||||
@model.set("selectedFile", file)
|
||||
view.render()
|
||||
expect(view.$el).toContainElement("input[type=file]")
|
||||
expect(view.$el).not.toContainElement("#upload_error")
|
||||
expect(view.$(".action-upload")).not.toHaveClass("disabled")
|
||||
|
||||
it "should render an error with an invalid file type selected", ->
|
||||
view = createTestView(this)
|
||||
file = {name: "fake.png", "type": "image/png"}
|
||||
@mockFiles.push(file)
|
||||
@model.set("selectedFile", file)
|
||||
view.render()
|
||||
expect(view.$el).toContainElement("input[type=file]")
|
||||
expect(view.$el).toContainElement("#upload_error")
|
||||
expect(view.$(".action-upload")).toHaveClass("disabled")
|
||||
|
||||
it "should render an error with an invalid file type after a correct file type selected", ->
|
||||
view = createTestView(this)
|
||||
correctFile = {name: "fake.pdf", "type": "application/pdf"}
|
||||
inCorrectFile = {name: "fake.png", "type": "image/png"}
|
||||
event = {}
|
||||
view.render()
|
||||
|
||||
event.target = {"files": [correctFile]}
|
||||
view.selectFile(event)
|
||||
expect(view.$el).toContainElement("input[type=file]")
|
||||
expect(view.$el).not.toContainElement("#upload_error")
|
||||
expect(view.$(".action-upload")).not.toHaveClass("disabled")
|
||||
|
||||
realMethod = @model.set
|
||||
spyOn(@model, "set").and.callFake (data) ->
|
||||
if data.selectedFile != undefined
|
||||
this.attributes.selectedFile = data.selectedFile
|
||||
this.changed = {}
|
||||
else
|
||||
realMethod.apply(this, arguments)
|
||||
|
||||
event.target = {"files": [inCorrectFile]}
|
||||
view.selectFile(event)
|
||||
expect(view.$el).toContainElement("input[type=file]")
|
||||
expect(view.$el).toContainElement("#upload_error")
|
||||
expect(view.$(".action-upload")).toHaveClass("disabled")
|
||||
|
||||
describe "Uploads", ->
|
||||
beforeEach ->
|
||||
@clock = sinon.useFakeTimers()
|
||||
modal_helpers.installModalTemplates()
|
||||
appendSetFixtures($("<script>", {id: "upload-dialog-tpl", type: "text/template"}).text(tpl))
|
||||
CMS.URL.UPLOAD_ASSET = "/upload"
|
||||
@model = new FileUpload(
|
||||
mimeTypes: ['application/pdf']
|
||||
)
|
||||
@dialogResponse = dialogResponse = []
|
||||
@mockFiles = []
|
||||
|
||||
afterEach ->
|
||||
delete CMS.URL.UPLOAD_ASSET
|
||||
modal_helpers.cancelModalIfShowing()
|
||||
@clock.restore()
|
||||
|
||||
it "can upload correctly", ->
|
||||
requests = AjaxHelpers.requests(this);
|
||||
view = createTestView(this)
|
||||
view.render()
|
||||
view.upload()
|
||||
expect(@model.get("uploading")).toBeTruthy()
|
||||
AjaxHelpers.expectRequest(requests, "POST", "/upload")
|
||||
AjaxHelpers.respondWithJson(requests, { response: "dummy_response"})
|
||||
expect(@model.get("uploading")).toBeFalsy()
|
||||
expect(@model.get("finished")).toBeTruthy()
|
||||
expect(@dialogResponse.pop()).toEqual("dummy_response")
|
||||
createTestView = (test) ->
|
||||
view = new UploadDialog(
|
||||
model: test.model,
|
||||
url: CMS.URL.UPLOAD_ASSET,
|
||||
onSuccess: (response) =>
|
||||
test.dialogResponse.push(response.response)
|
||||
)
|
||||
spyOn(view, 'remove').and.callThrough()
|
||||
|
||||
it "can handle upload errors", ->
|
||||
requests = AjaxHelpers.requests(this);
|
||||
view = createTestView(this)
|
||||
view.render()
|
||||
view.upload()
|
||||
AjaxHelpers.respondWithError(requests)
|
||||
expect(@model.get("title")).toMatch(/error/)
|
||||
expect(view.remove).not.toHaveBeenCalled()
|
||||
# create mock file input, so that we aren't subject to browser restrictions
|
||||
mockFileInput = jasmine.createSpy('mockFileInput')
|
||||
mockFileInput.files = test.mockFiles
|
||||
jqMockFileInput = jasmine.createSpyObj('jqMockFileInput', ['get', 'replaceWith'])
|
||||
jqMockFileInput.get.and.returnValue(mockFileInput)
|
||||
originalView$ = view.$
|
||||
spyOn(view, "$").and.callFake (selector) ->
|
||||
if selector == "input[type=file]"
|
||||
jqMockFileInput
|
||||
else
|
||||
originalView$.apply(this, arguments)
|
||||
@lastView = view
|
||||
|
||||
it "removes itself after two seconds on successful upload", ->
|
||||
requests = AjaxHelpers.requests(this);
|
||||
view = createTestView(this)
|
||||
view.render()
|
||||
view.upload()
|
||||
AjaxHelpers.respondWithJson(requests, { response: "dummy_response"})
|
||||
expect(modal_helpers.isShowingModal(view)).toBeTruthy();
|
||||
@clock.tick(2001)
|
||||
expect(modal_helpers.isShowingModal(view)).toBeFalsy();
|
||||
describe "Basic", ->
|
||||
it "should render without a file selected", ->
|
||||
view = createTestView(this)
|
||||
view.render()
|
||||
expect(view.$el).toContainElement("input[type=file]")
|
||||
expect(view.$(".action-upload")).toHaveClass("disabled")
|
||||
|
||||
it "should render with a PDF selected", ->
|
||||
view = createTestView(this)
|
||||
file = {name: "fake.pdf", "type": "application/pdf"}
|
||||
@mockFiles.push(file)
|
||||
@model.set("selectedFile", file)
|
||||
view.render()
|
||||
expect(view.$el).toContainElement("input[type=file]")
|
||||
expect(view.$el).not.toContainElement("#upload_error")
|
||||
expect(view.$(".action-upload")).not.toHaveClass("disabled")
|
||||
|
||||
it "should render an error with an invalid file type selected", ->
|
||||
view = createTestView(this)
|
||||
file = {name: "fake.png", "type": "image/png"}
|
||||
@mockFiles.push(file)
|
||||
@model.set("selectedFile", file)
|
||||
view.render()
|
||||
expect(view.$el).toContainElement("input[type=file]")
|
||||
expect(view.$el).toContainElement("#upload_error")
|
||||
expect(view.$(".action-upload")).toHaveClass("disabled")
|
||||
|
||||
it "should render an error with an invalid file type after a correct file type selected", ->
|
||||
view = createTestView(this)
|
||||
correctFile = {name: "fake.pdf", "type": "application/pdf"}
|
||||
inCorrectFile = {name: "fake.png", "type": "image/png"}
|
||||
event = {}
|
||||
view.render()
|
||||
|
||||
event.target = {"files": [correctFile]}
|
||||
view.selectFile(event)
|
||||
expect(view.$el).toContainElement("input[type=file]")
|
||||
expect(view.$el).not.toContainElement("#upload_error")
|
||||
expect(view.$(".action-upload")).not.toHaveClass("disabled")
|
||||
|
||||
realMethod = @model.set
|
||||
spyOn(@model, "set").and.callFake (data) ->
|
||||
if data.selectedFile != undefined
|
||||
this.attributes.selectedFile = data.selectedFile
|
||||
this.changed = {}
|
||||
else
|
||||
realMethod.apply(this, arguments)
|
||||
|
||||
event.target = {"files": [inCorrectFile]}
|
||||
view.selectFile(event)
|
||||
expect(view.$el).toContainElement("input[type=file]")
|
||||
expect(view.$el).toContainElement("#upload_error")
|
||||
expect(view.$(".action-upload")).toHaveClass("disabled")
|
||||
|
||||
describe "Uploads", ->
|
||||
beforeEach ->
|
||||
@clock = sinon.useFakeTimers()
|
||||
|
||||
afterEach ->
|
||||
modal_helpers.cancelModalIfShowing()
|
||||
@clock.restore()
|
||||
|
||||
it "can upload correctly", ->
|
||||
requests = AjaxHelpers.requests(this);
|
||||
view = createTestView(this)
|
||||
view.render()
|
||||
view.upload()
|
||||
expect(@model.get("uploading")).toBeTruthy()
|
||||
AjaxHelpers.expectRequest(requests, "POST", "/upload")
|
||||
AjaxHelpers.respondWithJson(requests, { response: "dummy_response"})
|
||||
expect(@model.get("uploading")).toBeFalsy()
|
||||
expect(@model.get("finished")).toBeTruthy()
|
||||
expect(@dialogResponse.pop()).toEqual("dummy_response")
|
||||
|
||||
it "can handle upload errors", ->
|
||||
requests = AjaxHelpers.requests(this);
|
||||
view = createTestView(this)
|
||||
view.render()
|
||||
view.upload()
|
||||
AjaxHelpers.respondWithError(requests)
|
||||
expect(@model.get("title")).toMatch(/error/)
|
||||
expect(view.remove).not.toHaveBeenCalled()
|
||||
|
||||
it "removes itself after two seconds on successful upload", ->
|
||||
requests = AjaxHelpers.requests(this);
|
||||
view = createTestView(this)
|
||||
view.render()
|
||||
view.upload()
|
||||
AjaxHelpers.respondWithJson(requests, { response: "dummy_response"})
|
||||
expect(modal_helpers.isShowingModal(view)).toBeTruthy();
|
||||
@clock.tick(2001)
|
||||
expect(modal_helpers.isShowingModal(view)).toBeFalsy();
|
||||
|
||||
@@ -8,7 +8,7 @@ define([ // jshint ignore:line
|
||||
'js/certificates/views/certificate_details',
|
||||
'js/certificates/views/certificate_preview',
|
||||
'common/js/components/views/feedback_notification',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'common/js/spec_helpers/view_helpers',
|
||||
'js/spec_helpers/validation_helpers',
|
||||
|
||||
@@ -8,7 +8,7 @@ define([ // jshint ignore:line
|
||||
'js/certificates/collections/certificates',
|
||||
'js/certificates/views/certificate_editor',
|
||||
'common/js/components/views/feedback_notification',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'common/js/spec_helpers/view_helpers',
|
||||
'js/spec_helpers/validation_helpers',
|
||||
|
||||
@@ -7,7 +7,7 @@ define([ // jshint ignore:line
|
||||
'js/certificates/views/certificate_preview',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'common/js/spec_helpers/view_helpers',
|
||||
'common/js/spec_helpers/ajax_helpers'
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers'
|
||||
],
|
||||
function(_, $, Course, CertificatePreview, TemplateHelpers, ViewHelpers, AjaxHelpers) {
|
||||
'use strict';
|
||||
|
||||
@@ -11,7 +11,7 @@ define([ // jshint ignore:line
|
||||
'js/certificates/views/certificates_list',
|
||||
'js/certificates/views/certificate_preview',
|
||||
'common/js/components/views/feedback_notification',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'js/certificates/spec/custom_matchers'
|
||||
],
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
define(["js/utils/drag_and_drop", "common/js/components/views/feedback_notification", "common/js/spec_helpers/ajax_helpers", "jquery", "underscore"],
|
||||
define(["js/utils/drag_and_drop", "common/js/components/views/feedback_notification",
|
||||
"edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "jquery", "underscore"],
|
||||
function (ContentDragger, Notification, AjaxHelpers, $, _) {
|
||||
describe("Overview drag and drop functionality", function () {
|
||||
beforeEach(function () {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
define(
|
||||
[
|
||||
'jquery', 'underscore',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'js/views/video/transcripts/utils',
|
||||
'js/views/video/transcripts/metadata_videolist', 'js/models/metadata',
|
||||
'js/views/abstract_editor',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'xmodule'
|
||||
],
|
||||
function ($, _, Utils, VideoList, MetadataModel, AbstractEditor, AjaxHelpers) {
|
||||
function ($, _, AjaxHelpers, Utils, VideoList, MetadataModel, AbstractEditor) {
|
||||
'use strict';
|
||||
describe('CMS.Views.Metadata.VideoList', function () {
|
||||
var videoListEntryTemplate = readFixtures(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define([ "jquery", "common/js/spec_helpers/ajax_helpers", "URI", "js/views/assets",
|
||||
define([ "jquery", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "URI", "js/views/assets",
|
||||
"js/collections/asset", "common/js/spec_helpers/view_helpers"],
|
||||
function ($, AjaxHelpers, URI, AssetsView, AssetCollection, ViewHelpers) {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define([ "jquery", "common/js/spec_helpers/ajax_helpers", "js/spec_helpers/edit_helpers",
|
||||
define([ "jquery", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "js/spec_helpers/edit_helpers",
|
||||
"js/views/container", "js/models/xblock_info", "jquery.simulate",
|
||||
"xmodule", "coffee/src/main", "xblock/cms.runtime.v1"],
|
||||
function ($, AjaxHelpers, EditHelpers, ContainerView, XBlockInfo) {
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
define([
|
||||
'underscore', 'js/models/course', 'js/models/group_configuration', 'js/models/group',
|
||||
'js/collections/group_configuration', 'js/collections/group',
|
||||
'js/views/group_configuration_details', 'js/views/group_configurations_list', 'js/views/group_configuration_editor',
|
||||
'js/views/group_configuration_item', 'js/views/experiment_group_edit', 'js/views/content_group_list',
|
||||
'js/views/content_group_details', 'js/views/content_group_editor', 'js/views/content_group_item',
|
||||
'common/js/components/views/feedback_notification', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
|
||||
'common/js/spec_helpers/view_helpers'
|
||||
'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/js/spec_helpers/template_helpers',
|
||||
'common/js/spec_helpers/view_helpers', 'js/models/course', 'js/models/group_configuration', 'js/models/group',
|
||||
'js/collections/group_configuration', 'js/collections/group', 'js/views/group_configuration_details',
|
||||
'js/views/group_configurations_list', 'js/views/group_configuration_editor', 'js/views/group_configuration_item',
|
||||
'js/views/experiment_group_edit', 'js/views/content_group_list', 'js/views/content_group_details',
|
||||
'js/views/content_group_editor', 'js/views/content_group_item'
|
||||
], function(
|
||||
_, Course, GroupConfigurationModel, GroupModel, GroupConfigurationCollection, GroupCollection,
|
||||
GroupConfigurationDetailsView, GroupConfigurationsListView, GroupConfigurationEditorView,
|
||||
GroupConfigurationItemView, ExperimentGroupEditView, GroupList, ContentGroupDetailsView,
|
||||
ContentGroupEditorView, ContentGroupItemView, Notification, AjaxHelpers, TemplateHelpers, ViewHelpers
|
||||
_, AjaxHelpers, TemplateHelpers, ViewHelpers, Course, GroupConfigurationModel, GroupModel,
|
||||
GroupConfigurationCollection, GroupCollection, GroupConfigurationDetailsView, GroupConfigurationsListView,
|
||||
GroupConfigurationEditorView, GroupConfigurationItemView, ExperimentGroupEditView, GroupList,
|
||||
ContentGroupDetailsView, ContentGroupEditorView, ContentGroupItemView
|
||||
) {
|
||||
'use strict';
|
||||
var SELECTORS = {
|
||||
@@ -286,7 +285,7 @@ define([
|
||||
it('should hide empty usage appropriately', function() {
|
||||
this.model.set('showGroups', true);
|
||||
this.view.$('.hide-groups').click();
|
||||
assertHideEmptyUsages(this.view)
|
||||
assertHideEmptyUsages(this.view);
|
||||
});
|
||||
|
||||
it('should show non-empty usage appropriately', function() {
|
||||
@@ -298,7 +297,7 @@ define([
|
||||
this.view,
|
||||
'This Group Configuration is used in:',
|
||||
'Cannot delete when in use by an experiment'
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
it('should hide non-empty usage appropriately', function() {
|
||||
@@ -922,7 +921,7 @@ define([
|
||||
this.view,
|
||||
'This content group is used in:',
|
||||
'Cannot delete when in use by a unit'
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
it('should hide non-empty usage appropriately', function() {
|
||||
@@ -988,7 +987,7 @@ define([
|
||||
notificationSpy = ViewHelpers.createNotificationSpy();
|
||||
this.view.$(SELECTORS.inputName).val('New Content Group');
|
||||
|
||||
ViewHelpers.submitAndVerifyFormError(this.view, requests, notificationSpy)
|
||||
ViewHelpers.submitAndVerifyFormError(this.view, requests, notificationSpy);
|
||||
});
|
||||
|
||||
it('does not save on cancel', function() {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
define(['jquery', 'js/factories/login', 'common/js/spec_helpers/ajax_helpers', 'common/js/components/utils/view_utils'],
|
||||
define(['jquery', 'js/factories/login', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/components/utils/view_utils'],
|
||||
function($, LoginFactory, AjaxHelpers, ViewUtils) {
|
||||
'use strict';
|
||||
describe("Studio Login Page", function() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(["jquery", "underscore", "common/js/spec_helpers/ajax_helpers", "js/spec_helpers/edit_helpers",
|
||||
define(["jquery", "underscore", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "js/spec_helpers/edit_helpers",
|
||||
"js/views/modals/edit_xblock", "js/models/xblock_info"],
|
||||
function ($, _, AjaxHelpers, EditHelpers, EditXBlockModal, XBlockInfo) {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(["jquery", "underscore", "common/js/spec_helpers/ajax_helpers", "URI", "js/models/xblock_info",
|
||||
define(["jquery", "underscore", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "URI", "js/models/xblock_info",
|
||||
"js/views/paged_container", "js/views/paging_header",
|
||||
"common/js/components/views/paging_footer", "js/views/xblock"],
|
||||
function ($, _, AjaxHelpers, URI, XBlockInfo, PagedContainer, PagingHeader, PagingFooter, XBlockView) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(["jquery", "underscore", "underscore.string", "common/js/spec_helpers/ajax_helpers",
|
||||
define(["jquery", "underscore", "underscore.string", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers",
|
||||
"common/js/spec_helpers/template_helpers", "js/spec_helpers/edit_helpers",
|
||||
"js/views/pages/container", "js/views/pages/paged_container", "js/models/xblock_info", "jquery.simulate"],
|
||||
function ($, _, str, AjaxHelpers, TemplateHelpers, EditHelpers, ContainerPage, PagedContainerPage, XBlockInfo) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(["jquery", "underscore", "underscore.string", "common/js/spec_helpers/ajax_helpers",
|
||||
define(["jquery", "underscore", "underscore.string", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers",
|
||||
"common/js/spec_helpers/template_helpers", "js/spec_helpers/edit_helpers",
|
||||
"common/js/components/views/feedback_prompt", "js/views/pages/container",
|
||||
"js/views/pages/container_subviews", "js/models/xblock_info", "js/views/utils/xblock_utils",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define(["jquery", "common/js/spec_helpers/ajax_helpers", "common/js/components/utils/view_utils", "js/views/pages/course_outline",
|
||||
"js/models/xblock_outline_info", "js/utils/date_utils", "js/spec_helpers/edit_helpers",
|
||||
"common/js/spec_helpers/template_helpers", 'js/models/course',],
|
||||
define(["jquery", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "common/js/components/utils/view_utils",
|
||||
"js/views/pages/course_outline", "js/models/xblock_outline_info", "js/utils/date_utils",
|
||||
"js/spec_helpers/edit_helpers", "common/js/spec_helpers/template_helpers", 'js/models/course'],
|
||||
function($, AjaxHelpers, ViewUtils, CourseOutlinePage, XBlockOutlineInfo, DateUtils,
|
||||
EditHelpers, TemplateHelpers, Course) {
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
define(["jquery", "common/js/spec_helpers/ajax_helpers", "common/js/spec_helpers/view_helpers", "js/views/course_rerun",
|
||||
"js/views/utils/create_course_utils", "common/js/components/utils/view_utils", "jquery.simulate"],
|
||||
define(["jquery", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "common/js/spec_helpers/view_helpers",
|
||||
"js/views/course_rerun", "js/views/utils/create_course_utils", "common/js/components/utils/view_utils",
|
||||
"jquery.simulate"],
|
||||
function ($, AjaxHelpers, ViewHelpers, CourseRerunUtils, CreateCourseUtilsFactory, ViewUtils) {
|
||||
describe("Create course rerun page", function () {
|
||||
var selectors = {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
define(["jquery", "common/js/spec_helpers/ajax_helpers", "common/js/spec_helpers/view_helpers", "js/index",
|
||||
define(["jquery",
|
||||
"edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers",
|
||||
"common/js/spec_helpers/view_helpers", "js/index",
|
||||
"common/js/components/utils/view_utils"],
|
||||
function ($, AjaxHelpers, ViewHelpers, IndexUtils, ViewUtils) {
|
||||
describe("Course listing page", function () {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define([
|
||||
"jquery", "common/js/spec_helpers/ajax_helpers", "common/js/spec_helpers/view_helpers",
|
||||
"jquery", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "common/js/spec_helpers/view_helpers",
|
||||
"js/factories/manage_users_lib", "common/js/components/utils/view_utils"
|
||||
],
|
||||
function ($, AjaxHelpers, ViewHelpers, ManageUsersFactory, ViewUtils) {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
define([
|
||||
"jquery",
|
||||
"URI",
|
||||
"common/js/spec_helpers/ajax_helpers",
|
||||
"edx-ui-toolkit/js/pagination/paging-collection",
|
||||
"js/views/paging",
|
||||
"js/views/paging_header"
|
||||
], function ($, URI, AjaxHelpers, PagingCollection, PagingView, PagingHeader) {
|
||||
"jquery",
|
||||
"URI",
|
||||
"edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers",
|
||||
"edx-ui-toolkit/js/pagination/paging-collection",
|
||||
"js/views/paging",
|
||||
"js/views/paging_header"
|
||||
],
|
||||
function ($, URI, AjaxHelpers, PagingCollection, PagingView, PagingHeader) {
|
||||
'use strict';
|
||||
|
||||
var createPageableItem = function(index) {
|
||||
var id = 'item_' + index;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define([
|
||||
'jquery', 'js/models/settings/course_details', 'js/views/settings/main',
|
||||
'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/js/spec_helpers/template_helpers',
|
||||
], function($, CourseDetailsModel, MainView, AjaxHelpers, TemplateHelpers) {
|
||||
'use strict';
|
||||
|
||||
@@ -125,10 +125,9 @@ define([
|
||||
//input some invalid values.
|
||||
expect(entrance_exam_min_score.val('101').trigger('input')).toHaveClass("error");
|
||||
expect(entrance_exam_min_score.val('invalidVal').trigger('input')).toHaveClass("error");
|
||||
|
||||
});
|
||||
|
||||
it('should provide a default value for the minimum score percentage', function(){
|
||||
it('should provide a default value for the minimum score percentage', function() {
|
||||
|
||||
var entrance_exam_min_score = this.view.$(SELECTORS.entrance_exam_min_score);
|
||||
|
||||
@@ -138,7 +137,7 @@ define([
|
||||
.toEqual(this.model.defaults.entrance_exam_minimum_score_pct);
|
||||
});
|
||||
|
||||
it('show and hide the grade requirement section when the check box is selected and deselected respectively', function(){
|
||||
it('shows and hide the grade requirement section appropriately', function() {
|
||||
|
||||
var entrance_exam_enabled_field = this.view.$(SELECTORS.entrance_exam_enabled_field);
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
define(["jquery", "common/js/spec_helpers/ajax_helpers", "common/js/spec_helpers/template_helpers",
|
||||
define(["jquery", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "common/js/spec_helpers/template_helpers",
|
||||
"common/js/spec_helpers/view_helpers", "common/js/components/utils/view_utils", "js/models/course",
|
||||
"js/views/unit_outline", "js/models/xblock_info"],
|
||||
function ($, AjaxHelpers, TemplateHelpers, ViewHelpers, ViewUtils,
|
||||
function($, AjaxHelpers, TemplateHelpers, ViewHelpers, ViewUtils,
|
||||
Course, UnitOutlineView, XBlockInfo) {
|
||||
'use strict';
|
||||
|
||||
describe("UnitOutlineView", function() {
|
||||
var createUnitOutlineView, createMockXBlockInfo,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define([ "jquery", "underscore", "common/js/spec_helpers/ajax_helpers", "js/spec_helpers/edit_helpers",
|
||||
define([ "jquery", "underscore", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "js/spec_helpers/edit_helpers",
|
||||
"js/views/xblock_editor", "js/models/xblock_info"],
|
||||
function ($, _, AjaxHelpers, EditHelpers, XBlockEditorView, XBlockInfo) {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(["jquery", "URI", "common/js/spec_helpers/ajax_helpers", "common/js/components/utils/view_utils",
|
||||
define(["jquery", "URI", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "common/js/components/utils/view_utils",
|
||||
"js/views/xblock", "js/models/xblock_info", "xmodule", "coffee/src/main", "xblock/cms.runtime.v1"],
|
||||
function ($, URI, AjaxHelpers, ViewUtils, XBlockView, XBlockInfo) {
|
||||
"use strict";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(["jquery", "common/js/spec_helpers/ajax_helpers", "common/js/spec_helpers/template_helpers",
|
||||
define(["jquery", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "common/js/spec_helpers/template_helpers",
|
||||
"js/spec_helpers/edit_helpers", "js/models/xblock_info", "js/views/xblock_string_field_editor"],
|
||||
function ($, AjaxHelpers, TemplateHelpers, EditHelpers, XBlockInfo, XBlockStringFieldEditor) {
|
||||
describe("XBlockStringFieldEditorView", function () {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* Provides helper methods for invoking Studio editors in Jasmine tests.
|
||||
*/
|
||||
define(["jquery", "underscore", "common/js/spec_helpers/ajax_helpers", "common/js/spec_helpers/template_helpers",
|
||||
"js/spec_helpers/modal_helpers", "js/views/modals/edit_xblock", "js/collections/component_template",
|
||||
"xmodule", "coffee/src/main", "xblock/cms.runtime.v1"],
|
||||
define(["jquery", "underscore", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers",
|
||||
"common/js/spec_helpers/template_helpers", "js/spec_helpers/modal_helpers", "js/views/modals/edit_xblock",
|
||||
"js/collections/component_template", "xmodule", "coffee/src/main", "xblock/cms.runtime.v1"],
|
||||
function($, _, AjaxHelpers, TemplateHelpers, modal_helpers, EditXBlockModal, ComponentTemplates) {
|
||||
|
||||
var installMockXBlock, uninstallMockXBlock, installMockXModule, uninstallMockXModule,
|
||||
|
||||
@@ -3,7 +3,7 @@ define([
|
||||
'backbone',
|
||||
'underscore',
|
||||
'edx-ui-toolkit/js/pagination/paging-collection',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/components/views/paginated_view'
|
||||
], function ($, Backbone, _, PagingCollection, AjaxHelpers, PaginatedView) {
|
||||
'use strict';
|
||||
|
||||
@@ -3,7 +3,7 @@ define([
|
||||
'URI',
|
||||
'underscore',
|
||||
'edx-ui-toolkit/js/pagination/paging-collection',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/components/views/paging_footer'
|
||||
], function ($, URI, _, PagingCollection, AjaxHelpers, PagingFooter) {
|
||||
'use strict';
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
define([
|
||||
'underscore',
|
||||
'URI',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'edx-ui-toolkit/js/pagination/paging-collection',
|
||||
'common/js/components/views/search_field',
|
||||
'common/js/spec_helpers/ajax_helpers'
|
||||
], function (_, URI, PagingCollection, SearchFieldView, AjaxHelpers) {
|
||||
'common/js/components/views/search_field'
|
||||
], function(_, URI, AjaxHelpers, PagingCollection, SearchFieldView) {
|
||||
'use strict';
|
||||
describe('SearchFieldView', function () {
|
||||
describe('SearchFieldView', function() {
|
||||
var searchFieldView,
|
||||
mockUrl = '/api/mock_collection';
|
||||
|
||||
var newCollection = function (size, perPage) {
|
||||
var results = _.map(_.range(size), function (i) { return {foo: i}; });
|
||||
var newCollection = function(size, perPage) {
|
||||
var results = _.map(_.range(size), function(i) { return {foo: i}; });
|
||||
var TestPagingCollection = PagingCollection.extend({
|
||||
state: {
|
||||
pageSize: 5
|
||||
@@ -29,7 +29,7 @@ define([
|
||||
return collection;
|
||||
};
|
||||
|
||||
var createSearchFieldView = function (options) {
|
||||
var createSearchFieldView = function(options) {
|
||||
options = _.extend(
|
||||
{
|
||||
type: 'test',
|
||||
@@ -41,14 +41,14 @@ define([
|
||||
return new SearchFieldView(options);
|
||||
};
|
||||
|
||||
var assertQueryParams = function (request, expectedParameters) {
|
||||
var assertQueryParams = function(request, expectedParameters) {
|
||||
var urlParams = new URI(request.url).query(true);
|
||||
_.each(expectedParameters, function (value, key) {
|
||||
_.each(expectedParameters, function(value, key) {
|
||||
expect(urlParams[key]).toBe(value);
|
||||
});
|
||||
};
|
||||
|
||||
var assertNotInQueryParams = function (request, param) {
|
||||
var assertNotInQueryParams = function(request, param) {
|
||||
var urlParams = new URI(request.url).query(true);
|
||||
return !urlParams.hasOwnProperty(param);
|
||||
};
|
||||
@@ -57,20 +57,20 @@ define([
|
||||
setFixtures('<section class="test-search"></section>');
|
||||
});
|
||||
|
||||
it('correctly displays itself', function () {
|
||||
it('correctly displays itself', function() {
|
||||
searchFieldView = createSearchFieldView().render();
|
||||
expect(searchFieldView.$('.search-field').val(), '');
|
||||
expect(searchFieldView.$('.action-clear')).toHaveClass('is-hidden');
|
||||
});
|
||||
|
||||
it('can display with an initial search string', function () {
|
||||
it('can display with an initial search string', function() {
|
||||
searchFieldView = createSearchFieldView({
|
||||
searchString: 'foo'
|
||||
}).render();
|
||||
expect(searchFieldView.$('.search-field').val(), 'foo');
|
||||
});
|
||||
|
||||
it('refreshes the collection when performing a search', function () {
|
||||
it('refreshes the collection when performing a search', function() {
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
searchFieldView = createSearchFieldView().render();
|
||||
searchFieldView.$('.search-field').val('foo');
|
||||
@@ -80,7 +80,7 @@ define([
|
||||
page_size: '5',
|
||||
text_search: 'foo'
|
||||
});
|
||||
|
||||
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
count: 10,
|
||||
page: 1,
|
||||
@@ -90,7 +90,7 @@ define([
|
||||
expect(searchFieldView.$('.search-field').val(), 'foo');
|
||||
});
|
||||
|
||||
it('can clear the search', function () {
|
||||
it('can clear the search', function() {
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
searchFieldView = createSearchFieldView({
|
||||
searchString: 'foo'
|
||||
|
||||
@@ -1,207 +0,0 @@
|
||||
define(['sinon', 'underscore', 'URI'], function(sinon, _, URI) {
|
||||
'use strict';
|
||||
|
||||
var XML_HTTP_READY_STATES, fakeServer, fakeRequests, currentRequest, expectRequest, expectNoRequests,
|
||||
expectJsonRequest, expectPostRequest, expectRequestURL, skipResetRequest,
|
||||
respondWithJson, respondWithError, respondWithTextError, respondWithNoContent;
|
||||
|
||||
XML_HTTP_READY_STATES = {
|
||||
UNSENT: 0,
|
||||
OPENED: 1,
|
||||
LOADING: 3,
|
||||
DONE: 4
|
||||
};
|
||||
|
||||
/* These utility methods are used by Jasmine tests to create a mock server or
|
||||
* get reference to mock requests. In either case, the cleanup (restore) is done with
|
||||
* an after function.
|
||||
*
|
||||
* This pattern is being used instead of the more common beforeEach/afterEach pattern
|
||||
* because we were seeing sporadic failures in the afterEach restore call. The cause of the
|
||||
* errors were that one test suite was incorrectly being linked as the parent of an unrelated
|
||||
* test suite (causing both suites' afterEach methods to be called). No solution for the root
|
||||
* cause has been found, but initializing sinon and cleaning it up on a method-by-method
|
||||
* basis seems to work. For more details, see STUD-1264.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get a reference to the mocked server, and respond
|
||||
* to all requests with the specified statusCode.
|
||||
*/
|
||||
fakeServer = function (response) {
|
||||
var server = sinon.fakeServer.create();
|
||||
afterEach(function() {
|
||||
if (server) {
|
||||
server.restore();
|
||||
}
|
||||
});
|
||||
server.respondWith(response);
|
||||
return server;
|
||||
};
|
||||
|
||||
/**
|
||||
* Keep track of all requests to a fake server, and
|
||||
* return a reference to the Array. This allows tests
|
||||
* to respond for individual requests.
|
||||
*/
|
||||
fakeRequests = function () {
|
||||
var requests = [],
|
||||
xhr = sinon.useFakeXMLHttpRequest();
|
||||
|
||||
requests.currentIndex = 0;
|
||||
xhr.onCreate = function(request) {
|
||||
requests.push(request);
|
||||
};
|
||||
|
||||
afterEach(function() {
|
||||
if (xhr && xhr.hasOwnProperty('restore')) {
|
||||
xhr.restore();
|
||||
}
|
||||
});
|
||||
return requests;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the request that has not yet been responded to. If no such request
|
||||
* is available then the current test will fail.
|
||||
* @param requests The Sinon requests list.
|
||||
* @returns {*} The current request.
|
||||
*/
|
||||
currentRequest = function(requests) {
|
||||
expect(requests.length).toBeGreaterThan(requests.currentIndex);
|
||||
return requests[requests.currentIndex];
|
||||
};
|
||||
|
||||
expectRequest = function(requests, method, url, body) {
|
||||
var request = currentRequest(requests);
|
||||
expect(request.readyState).toEqual(XML_HTTP_READY_STATES.OPENED);
|
||||
expect(request.url).toEqual(url);
|
||||
expect(request.method).toEqual(method);
|
||||
if (typeof body === 'undefined') {
|
||||
// The body of the request may not be germane to the current test-- like some call by a library,
|
||||
// so allow it to be ignored.
|
||||
return;
|
||||
}
|
||||
expect(request.requestBody).toEqual(body);
|
||||
};
|
||||
|
||||
/**
|
||||
* Verifies the there are no unconsumed requests.
|
||||
*/
|
||||
expectNoRequests = function(requests) {
|
||||
expect(requests.length).toEqual(requests.currentIndex);
|
||||
};
|
||||
|
||||
expectJsonRequest = function(requests, method, url, jsonRequest) {
|
||||
jsonRequest = jsonRequest || null;
|
||||
var request = currentRequest(requests);
|
||||
expect(request.readyState).toEqual(XML_HTTP_READY_STATES.OPENED);
|
||||
expect(request.url).toEqual(url);
|
||||
expect(request.method).toEqual(method);
|
||||
expect(JSON.parse(request.requestBody)).toEqual(jsonRequest === undefined ? null : jsonRequest);
|
||||
};
|
||||
|
||||
/**
|
||||
* Expect that a JSON request be made with the given URL and parameters.
|
||||
* @param requests The collected requests
|
||||
* @param expectedUrl The expected URL excluding the parameters
|
||||
* @param expectedParameters An object representing the URL parameters
|
||||
*/
|
||||
expectRequestURL = function(requests, expectedUrl, expectedParameters) {
|
||||
var request = currentRequest(requests),
|
||||
parameters;
|
||||
expect(new URI(request.url).path()).toEqual(expectedUrl);
|
||||
parameters = new URI(request.url).query(true);
|
||||
delete parameters._; // Ignore the cache-busting argument
|
||||
expect(parameters).toEqual(expectedParameters);
|
||||
};
|
||||
|
||||
/**
|
||||
* Intended for use with POST requests using application/x-www-form-urlencoded.
|
||||
*/
|
||||
expectPostRequest = function(requests, url, body) {
|
||||
var request = currentRequest(requests);
|
||||
expect(request.readyState).toEqual(XML_HTTP_READY_STATES.OPENED);
|
||||
expect(request.url).toEqual(url);
|
||||
expect(request.method).toEqual("POST");
|
||||
expect(_.difference(request.requestBody.split('&'), body.split('&'))).toEqual([]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Verify that the HTTP request was marked as reset, and then skip it.
|
||||
*
|
||||
* Note: this is typically used when code has explicitly canceled a request
|
||||
* after it has been sent. A good example is when a user chooses to cancel
|
||||
* a slow running search.
|
||||
*/
|
||||
skipResetRequest = function(requests) {
|
||||
var request = currentRequest(requests);
|
||||
expect(request.readyState).toEqual(XML_HTTP_READY_STATES.UNSENT);
|
||||
requests.currentIndex++;
|
||||
};
|
||||
|
||||
respondWithJson = function(requests, jsonResponse) {
|
||||
var request = currentRequest(requests);
|
||||
request.respond(200,
|
||||
{ 'Content-Type': 'application/json' },
|
||||
JSON.stringify(jsonResponse));
|
||||
requests.currentIndex++;
|
||||
};
|
||||
|
||||
respondWithError = function(requests, statusCode, jsonResponse) {
|
||||
var request = currentRequest(requests);
|
||||
if (_.isUndefined(statusCode)) {
|
||||
statusCode = 500;
|
||||
}
|
||||
if (_.isUndefined(jsonResponse)) {
|
||||
jsonResponse = {};
|
||||
}
|
||||
request.respond(
|
||||
statusCode,
|
||||
{ 'Content-Type': 'application/json' },
|
||||
JSON.stringify(jsonResponse)
|
||||
);
|
||||
requests.currentIndex++;
|
||||
};
|
||||
|
||||
respondWithTextError = function(requests, statusCode, textResponse) {
|
||||
var request = currentRequest(requests);
|
||||
if (_.isUndefined(statusCode)) {
|
||||
statusCode = 500;
|
||||
}
|
||||
if (_.isUndefined(textResponse)) {
|
||||
textResponse = "";
|
||||
}
|
||||
request.respond(
|
||||
statusCode,
|
||||
{ 'Content-Type': 'text/plain' },
|
||||
textResponse
|
||||
);
|
||||
requests.currentIndex++;
|
||||
};
|
||||
|
||||
respondWithNoContent = function(requests) {
|
||||
var request = currentRequest(requests);
|
||||
request.respond(
|
||||
204,
|
||||
{ 'Content-Type': 'application/json' }
|
||||
);
|
||||
requests.currentIndex++;
|
||||
};
|
||||
|
||||
return {
|
||||
server: fakeServer,
|
||||
requests: fakeRequests,
|
||||
currentRequest: currentRequest,
|
||||
expectRequest: expectRequest,
|
||||
expectNoRequests: expectNoRequests,
|
||||
expectJsonRequest: expectJsonRequest,
|
||||
expectPostRequest: expectPostRequest,
|
||||
expectRequestURL: expectRequestURL,
|
||||
skipResetRequest: skipResetRequest,
|
||||
respondWithJson: respondWithJson,
|
||||
respondWithError: respondWithError,
|
||||
respondWithTextError: respondWithTextError,
|
||||
respondWithNoContent: respondWithNoContent
|
||||
};
|
||||
});
|
||||
@@ -1,52 +0,0 @@
|
||||
/**
|
||||
* Generally useful helper functions for writing Jasmine unit tests.
|
||||
*/
|
||||
define([], function () {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Runs func as a test case multiple times, using entries from data as arguments. Like Python's DDT.
|
||||
* @param data An object mapping test names to arrays of function parameters. The name is passed to it() as the name
|
||||
* of the test case, and the list of arguments is applied as arguments to func.
|
||||
* @param func The function that actually expresses the logic of the test.
|
||||
*/
|
||||
var withData = function (data, func) {
|
||||
for (var name in data) {
|
||||
if (data.hasOwnProperty(name)) {
|
||||
(function (name) {
|
||||
it(name, function () {
|
||||
func.apply(this, data[name]);
|
||||
});
|
||||
})(name);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Runs test multiple times, wrapping each call in a describe with beforeEach specified by setup and arguments and
|
||||
* name coming from entries in config.
|
||||
* @param config An object mapping configuration names to arrays of setup function parameters. The name is passed
|
||||
* to describe as the name of the group of tests, and the list of arguments is applied as arguments to setup.
|
||||
* @param setup The function to setup the given configuration before each test case. Runs in beforeEach.
|
||||
* @param test The function that actually express the logic of the test. May include it() or more describe().
|
||||
*/
|
||||
var withConfiguration = function (config, setup, test) {
|
||||
for (var name in config) {
|
||||
if (config.hasOwnProperty(name)) {
|
||||
(function (name) {
|
||||
describe(name, function () {
|
||||
beforeEach(function () {
|
||||
setup.apply(this, config[name]);
|
||||
});
|
||||
test();
|
||||
});
|
||||
})(name);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
withData: withData,
|
||||
withConfiguration: withConfiguration
|
||||
};
|
||||
});
|
||||
@@ -4,7 +4,7 @@
|
||||
;(function (define) {
|
||||
'use strict';
|
||||
define(["jquery", "common/js/components/views/feedback_notification", "common/js/components/views/feedback_prompt",
|
||||
'common/js/spec_helpers/ajax_helpers'],
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers'],
|
||||
function($, NotificationView, Prompt, AjaxHelpers) {
|
||||
var installViewTemplates, createFeedbackSpy, verifyFeedbackShowing,
|
||||
verifyFeedbackHidden, createNotificationSpy, verifyNotificationShowing,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define([
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'support/js/spec_helpers/enrollment_helpers',
|
||||
'support/js/collections/enrollment',
|
||||
], function (AjaxHelpers, EnrollmentHelpers, EnrollmentCollection) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define([
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'support/js/spec_helpers/enrollment_helpers',
|
||||
'support/js/models/enrollment'
|
||||
], function (AjaxHelpers, EnrollmentHelpers, EnrollmentModel) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define([
|
||||
'jquery',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'support/js/views/certificates'
|
||||
], function($, AjaxHelpers, CertificatesView) {
|
||||
'use strict';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define([
|
||||
'underscore',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'support/js/spec_helpers/enrollment_helpers',
|
||||
'support/js/models/enrollment',
|
||||
'support/js/views/enrollment_modal'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define([
|
||||
'underscore',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'support/js/spec_helpers/enrollment_helpers',
|
||||
'support/js/views/enrollment'
|
||||
], function (_, AjaxHelpers, EnrollmentHelpers, EnrollmentView) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['backbone', 'URI', 'underscore', 'common/js/spec_helpers/ajax_helpers',
|
||||
define(['backbone', 'URI', 'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'teams/js/spec_helpers/team_spec_helpers'],
|
||||
function (Backbone, URI, _, AjaxHelpers, TeamSpecHelpers) {
|
||||
'use strict';
|
||||
|
||||
@@ -2,7 +2,7 @@ define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'teams/js/views/edit_team_members',
|
||||
'teams/js/models/team',
|
||||
'teams/js/views/team_utils',
|
||||
|
||||
@@ -2,7 +2,7 @@ define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/page_helpers',
|
||||
'teams/js/views/edit_team',
|
||||
'teams/js/models/team',
|
||||
|
||||
@@ -6,7 +6,7 @@ define([
|
||||
'teams/js/views/instructor_tools',
|
||||
'teams/js/views/team_utils',
|
||||
'teams/js/spec_helpers/team_spec_helpers',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/page_helpers'
|
||||
], function ($, Backbone, _, Team, InstructorToolsView, TeamUtils, TeamSpecHelpers, AjaxHelpers, PageHelpers) {
|
||||
'use strict';
|
||||
|
||||
@@ -3,7 +3,7 @@ define([
|
||||
'teams/js/collections/my_teams',
|
||||
'teams/js/views/my_teams',
|
||||
'teams/js/spec_helpers/team_spec_helpers',
|
||||
'common/js/spec_helpers/ajax_helpers'
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers'
|
||||
], function (Backbone, MyTeamsCollection, MyTeamsView, TeamSpecHelpers, AjaxHelpers) {
|
||||
'use strict';
|
||||
describe('My Teams View', function () {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define([
|
||||
'underscore', 'common/js/spec_helpers/ajax_helpers', 'teams/js/views/team_discussion',
|
||||
'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'teams/js/views/team_discussion',
|
||||
'teams/js/spec_helpers/team_spec_helpers',
|
||||
'xmodule_js/common_static/coffee/spec/discussion/discussion_spec_helper'
|
||||
], function (_, AjaxHelpers, TeamDiscussionView, TeamSpecHelpers, DiscussionSpecHelper) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define([
|
||||
'backbone', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'teams/js/models/team',
|
||||
'backbone', 'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'teams/js/models/team',
|
||||
'teams/js/views/team_profile_header_actions', 'teams/js/spec_helpers/team_spec_helpers'
|
||||
], function (Backbone, _, AjaxHelpers, TeamModel, TeamProfileHeaderActionsView, TeamSpecHelpers) {
|
||||
'use strict';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define([
|
||||
'underscore', 'common/js/spec_helpers/ajax_helpers', 'teams/js/models/team',
|
||||
'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'teams/js/models/team',
|
||||
'teams/js/views/team_profile', 'teams/js/spec_helpers/team_spec_helpers',
|
||||
'xmodule_js/common_static/coffee/spec/discussion/discussion_spec_helper'
|
||||
], function (_, AjaxHelpers, TeamModel, TeamProfileView, TeamSpecHelpers, DiscussionSpecHelper) {
|
||||
|
||||
@@ -2,22 +2,22 @@ define([
|
||||
'jquery',
|
||||
'backbone',
|
||||
'logger',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/spec-helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/page_helpers',
|
||||
'common/js/spec_helpers/spec_helpers',
|
||||
'teams/js/views/teams_tab',
|
||||
'teams/js/spec_helpers/team_spec_helpers'
|
||||
], function ($, Backbone, Logger, AjaxHelpers, PageHelpers, SpecHelpers, TeamsTabView, TeamSpecHelpers) {
|
||||
], function($, Backbone, Logger, SpecHelpers, AjaxHelpers, PageHelpers, TeamsTabView, TeamSpecHelpers) {
|
||||
'use strict';
|
||||
|
||||
describe('TeamsTab', function() {
|
||||
var requests;
|
||||
|
||||
var expectError = function (teamsTabView, text) {
|
||||
var expectError = function(teamsTabView, text) {
|
||||
expect(teamsTabView.$('.warning').text()).toContain(text);
|
||||
};
|
||||
|
||||
var expectFocus = function (element) {
|
||||
var expectFocus = function(element) {
|
||||
expect(element.focus).toHaveBeenCalled();
|
||||
};
|
||||
|
||||
@@ -50,7 +50,7 @@ define([
|
||||
return teamsTabView;
|
||||
};
|
||||
|
||||
beforeEach(function () {
|
||||
beforeEach(function() {
|
||||
setFixtures('<div class="teams-content"></div>');
|
||||
spyOn($.fn, 'focus');
|
||||
spyOn(Logger, 'log');
|
||||
@@ -62,7 +62,7 @@ define([
|
||||
}
|
||||
);
|
||||
|
||||
describe('Navigation', function () {
|
||||
describe('Navigation', function() {
|
||||
it('does not render breadcrumbs for the top level tabs', function() {
|
||||
var teamsTabView = createTeamsTabView(this);
|
||||
teamsTabView.router.navigate('#my-teams', {trigger: true});
|
||||
@@ -71,20 +71,20 @@ define([
|
||||
expect(teamsTabView.$('.breadcrumbs').length).toBe(0);
|
||||
});
|
||||
|
||||
it('does not interfere with anchor links to #content', function () {
|
||||
it('does not interfere with anchor links to #content', function() {
|
||||
var teamsTabView = createTeamsTabView(this);
|
||||
teamsTabView.router.navigate('#content', {trigger: true});
|
||||
expect(teamsTabView.$('.wrapper-msg')).toHaveClass('is-hidden');
|
||||
});
|
||||
|
||||
it('displays and focuses an error message when trying to navigate to a nonexistent page', function () {
|
||||
it('displays and focuses an error message when trying to navigate to a nonexistent page', function() {
|
||||
var teamsTabView = createTeamsTabView(this);
|
||||
teamsTabView.router.navigate('no_such_page', {trigger: true});
|
||||
expectError(teamsTabView, 'The page "no_such_page" could not be found.');
|
||||
expectFocus(teamsTabView.$('.warning'));
|
||||
});
|
||||
|
||||
it('displays and focuses an error message when trying to navigate to a nonexistent topic', function () {
|
||||
it('displays and focuses an error message when trying to navigate to a nonexistent topic', function() {
|
||||
var teamsTabView = createTeamsTabView(this);
|
||||
teamsTabView.router.navigate('topics/no_such_topic', {trigger: true});
|
||||
AjaxHelpers.expectRequest(requests, 'GET', '/api/team/v0/topics/no_such_topic,course/1', null);
|
||||
@@ -93,7 +93,7 @@ define([
|
||||
expectFocus(teamsTabView.$('.warning'));
|
||||
});
|
||||
|
||||
it('displays and focuses an error message when trying to navigate to a nonexistent team', function () {
|
||||
it('displays and focuses an error message when trying to navigate to a nonexistent team', function() {
|
||||
var teamsTabView = createTeamsTabView(this);
|
||||
teamsTabView.router.navigate('teams/' + TeamSpecHelpers.testTopicID + '/no_such_team', {trigger: true});
|
||||
AjaxHelpers.expectRequest(requests, 'GET', '/api/team/v0/teams/no_such_team?expand=user', null);
|
||||
@@ -102,23 +102,27 @@ define([
|
||||
expectFocus(teamsTabView.$('.warning'));
|
||||
});
|
||||
|
||||
it('displays and focuses an error message when it receives a 401 AJAX response', function () {
|
||||
it('displays and focuses an error message when it receives a 401 AJAX response', function() {
|
||||
var teamsTabView = createTeamsTabView(this).render();
|
||||
teamsTabView.router.navigate('topics/' + TeamSpecHelpers.testTopicID, {trigger: true});
|
||||
AjaxHelpers.respondWithError(requests, 401);
|
||||
expectError(teamsTabView, "Your request could not be completed. Reload the page and try again.");
|
||||
expectError(teamsTabView, 'Your request could not be completed. Reload the page and try again.');
|
||||
expectFocus(teamsTabView.$('.warning'));
|
||||
});
|
||||
|
||||
it('displays and focuses an error message when it receives a 500 AJAX response', function () {
|
||||
it('displays and focuses an error message when it receives a 500 AJAX response', function() {
|
||||
var teamsTabView = createTeamsTabView(this).render();
|
||||
teamsTabView.router.navigate('topics/' + TeamSpecHelpers.testTopicID, {trigger: true});
|
||||
AjaxHelpers.respondWithError(requests, 500);
|
||||
expectError(teamsTabView, "Your request could not be completed due to a server problem. Reload the page and try again. If the issue persists, click the Help tab to report the problem.");
|
||||
expectError(
|
||||
teamsTabView,
|
||||
'Your request could not be completed due to a server problem. Reload the page and try again. ' +
|
||||
'If the issue persists, click the Help tab to report the problem.'
|
||||
);
|
||||
expectFocus(teamsTabView.$('.warning'));
|
||||
});
|
||||
|
||||
it('does not navigate to the topics page when syncing its collection if not on the search page', function () {
|
||||
it('does not navigate to the topics page when syncing its collection if not on search page', function() {
|
||||
var teamsTabView = createTeamsTabView(this),
|
||||
collection = TeamSpecHelpers.createMockTeams();
|
||||
teamsTabView.createTeamsListView({
|
||||
@@ -131,7 +135,7 @@ define([
|
||||
});
|
||||
});
|
||||
|
||||
describe('Analytics Events', function () {
|
||||
describe('Analytics Events', function() {
|
||||
SpecHelpers.withData({
|
||||
'fires a page view event for the topic page': [
|
||||
'topics/' + TeamSpecHelpers.testTopicID,
|
||||
@@ -173,7 +177,7 @@ define([
|
||||
team_id: 'test_team_id'
|
||||
}
|
||||
]
|
||||
}, function (url, expectedEvent) {
|
||||
}, function(url, expectedEvent) {
|
||||
var teamsTabView = createTeamsTabView(this, {
|
||||
userInfo: TeamSpecHelpers.createMockUserInfo({staff: true})
|
||||
});
|
||||
@@ -186,8 +190,8 @@ define([
|
||||
});
|
||||
});
|
||||
|
||||
describe('Discussion privileges', function () {
|
||||
it('allows privileged access to any team', function () {
|
||||
describe('Discussion privileges', function() {
|
||||
it('allows privileged access to any team', function() {
|
||||
var teamsTabView = createTeamsTabView(this, {
|
||||
userInfo: TeamSpecHelpers.createMockUserInfo({privileged: true})
|
||||
});
|
||||
@@ -197,7 +201,7 @@ define([
|
||||
expect(teamsTabView.readOnlyDiscussion(undefined)).toBe(false);
|
||||
});
|
||||
|
||||
it('allows access to a team which an unprivileged user is a member of', function () {
|
||||
it('allows access to a team which an unprivileged user is a member of', function() {
|
||||
var teamsTabView = createTeamsTabView(this, {
|
||||
userInfo: TeamSpecHelpers.createMockUserInfo({
|
||||
username: TeamSpecHelpers.testUser,
|
||||
@@ -215,7 +219,7 @@ define([
|
||||
})).toBe(false);
|
||||
});
|
||||
|
||||
it('does not allow access if the user is neither privileged nor a team member', function () {
|
||||
it('does not allow access if the user is neither privileged nor a team member', function() {
|
||||
var teamsTabView = createTeamsTabView(this, {
|
||||
userInfo: TeamSpecHelpers.createMockUserInfo({privileged: false, staff: true})
|
||||
});
|
||||
@@ -225,7 +229,7 @@ define([
|
||||
});
|
||||
});
|
||||
|
||||
describe('Search', function () {
|
||||
describe('Search', function() {
|
||||
var performSearch = function(requests, teamsTabView) {
|
||||
teamsTabView.$('.search-field').val('foo');
|
||||
teamsTabView.$('.action-search').click();
|
||||
@@ -239,7 +243,7 @@ define([
|
||||
AjaxHelpers.expectNoRequests(requests);
|
||||
};
|
||||
|
||||
it('can search teams', function () {
|
||||
it('can search teams', function() {
|
||||
var teamsTabView = createTeamsTabView(this);
|
||||
teamsTabView.browseTopic(TeamSpecHelpers.testTopicID);
|
||||
verifyTeamsRequest({
|
||||
@@ -252,7 +256,7 @@ define([
|
||||
expect(teamsTabView.$('.page-description').text()).toBe('Showing results for "foo"');
|
||||
});
|
||||
|
||||
it('can clear a search', function () {
|
||||
it('can clear a search', function() {
|
||||
var teamsTabView = createTeamsTabView(this);
|
||||
teamsTabView.browseTopic(TeamSpecHelpers.testTopicID);
|
||||
AjaxHelpers.respondWithJson(requests, {});
|
||||
@@ -272,7 +276,7 @@ define([
|
||||
expect(teamsTabView.$('.page-description').text()).toBe('Test description 1');
|
||||
});
|
||||
|
||||
it('can navigate back to all teams from a search', function () {
|
||||
it('can navigate back to all teams from a search', function() {
|
||||
var teamsTabView = createTeamsTabView(this);
|
||||
teamsTabView.browseTopic(TeamSpecHelpers.testTopicID);
|
||||
AjaxHelpers.respondWithJson(requests, {});
|
||||
@@ -292,7 +296,7 @@ define([
|
||||
expect(teamsTabView.$('.page-description').text()).toBe('Test description 1');
|
||||
});
|
||||
|
||||
it('does not switch to showing results when the search returns an error', function () {
|
||||
it('does not switch to showing results when the search returns an error', function() {
|
||||
var teamsTabView = createTeamsTabView(this);
|
||||
teamsTabView.browseTopic(TeamSpecHelpers.testTopicID);
|
||||
AjaxHelpers.respondWithJson(requests, {});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define([
|
||||
'backbone', 'underscore', 'teams/js/collections/topic', 'teams/js/views/topics',
|
||||
'teams/js/spec_helpers/team_spec_helpers', 'common/js/spec_helpers/ajax_helpers'
|
||||
'teams/js/spec_helpers/team_spec_helpers', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers'
|
||||
], function (Backbone, _, TopicCollection, TopicsView, TeamSpecHelpers, AjaxHelpers) {
|
||||
'use strict';
|
||||
describe('TopicsView', function () {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define([
|
||||
'js/api_admin/views/catalog_preview',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers'
|
||||
], function (
|
||||
CatalogPreviewView, AjaxHelpers
|
||||
) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['common/js/spec_helpers/ajax_helpers', 'js/ccx/schedule'],
|
||||
define(['edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'js/ccx/schedule'],
|
||||
function(AjaxHelpers) {
|
||||
describe("edx.ccx.schedule.ScheduleView", function() {
|
||||
var view = null;
|
||||
|
||||
@@ -2,9 +2,9 @@ define([
|
||||
'jquery',
|
||||
'jquery.ajax-retry',
|
||||
'js/commerce/views/receipt_view',
|
||||
'common/js/spec_helpers/ajax_helpers'
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers'
|
||||
],
|
||||
function ($, AjaxRetry, ReceiptView, AjaxHelpers){
|
||||
function ($, AjaxRetry, ReceiptView, AjaxHelpers) {
|
||||
'use strict';
|
||||
describe('edx.commerce.ReceiptView', function() {
|
||||
var data, courseResponseData, providerResponseData, mockRequests, mockRender, createReceiptView,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers',
|
||||
define(['backbone', 'jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/template_helpers', 'js/bookmarks/views/bookmark_button'
|
||||
],
|
||||
function (Backbone, $, _, AjaxHelpers, TemplateHelpers, BookmarkButtonView) {
|
||||
|
||||
@@ -3,7 +3,7 @@ define(['backbone',
|
||||
'underscore',
|
||||
'logger',
|
||||
'URI',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'js/bookmarks/views/bookmarks_list_button',
|
||||
'js/bookmarks/views/bookmarks_list',
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
define(['common/js/spec_helpers/template_helpers', 'common/js/spec_helpers/ajax_helpers', 'js/dashboard/donation'],
|
||||
define(['common/js/spec_helpers/template_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'js/dashboard/donation'],
|
||||
function(TemplateHelpers, AjaxHelpers) {
|
||||
'use strict';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define([
|
||||
'jquery', 'common/js/spec_helpers/ajax_helpers','common/js/spec_helpers/template_helpers',
|
||||
'jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers','common/js/spec_helpers/template_helpers',
|
||||
'js/discovery/discovery_factory'
|
||||
], function($, AjaxHelpers, TemplateHelpers, DiscoveryFactory) {
|
||||
'use strict';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define([
|
||||
'common/js/spec_helpers/ajax_helpers', 'js/discovery/models/course_discovery'
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'js/discovery/models/course_discovery'
|
||||
], function(AjaxHelpers, CourseDiscovery) {
|
||||
'use strict';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define([
|
||||
'common/js/spec_helpers/ajax_helpers', 'js/discovery/models/search_state'
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'js/discovery/models/search_state'
|
||||
], function(AjaxHelpers, SearchState) {
|
||||
'use strict';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['underscore', 'URI', 'common/js/spec_helpers/ajax_helpers'], function(_, URI, AjaxHelpers) {
|
||||
define(['underscore', 'URI', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers'], function(_, URI, AjaxHelpers) {
|
||||
'use strict';
|
||||
var B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
|
||||
LONG_TEXT, PRUNED_TEXT, TRUNCATED_TEXT, SHORT_TEXT,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define([
|
||||
'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'js/spec/edxnotes/helpers',
|
||||
'jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'js/spec/edxnotes/helpers',
|
||||
'annotator_1.2.9', 'logger', 'js/edxnotes/views/notes_factory'
|
||||
], function($, _, AjaxHelpers, Helpers, Annotator, Logger, NotesFactory) {
|
||||
'use strict';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define([
|
||||
'jquery', 'underscore', 'annotator_1.2.9',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'js/spec/edxnotes/helpers',
|
||||
'js/edxnotes/views/notes_factory'
|
||||
], function ($, _, Annotator, AjaxHelpers, Helpers, NotesFactory) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define([
|
||||
'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers',
|
||||
'jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/template_helpers', 'js/spec/edxnotes/helpers', 'logger',
|
||||
'js/edxnotes/models/note', 'js/edxnotes/views/note_item',
|
||||
], function(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define([
|
||||
'annotator_1.2.9', 'js/edxnotes/views/notes_factory', 'common/js/spec_helpers/ajax_helpers',
|
||||
'annotator_1.2.9', 'js/edxnotes/views/notes_factory', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'js/spec/edxnotes/helpers'
|
||||
], function(Annotator, NotesFactory, AjaxHelpers, Helpers) {
|
||||
'use strict';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define([
|
||||
'jquery', 'underscore', 'common/js/spec_helpers/template_helpers',
|
||||
'common/js/spec_helpers/ajax_helpers', 'js/spec/edxnotes/helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'js/spec/edxnotes/helpers',
|
||||
'js/edxnotes/views/page_factory'
|
||||
], function($, _, TemplateHelpers, AjaxHelpers, Helpers, NotesFactory) {
|
||||
'use strict';
|
||||
@@ -15,7 +15,6 @@ define([
|
||||
this.view = new NotesFactory({notes: notes, pageSize: 10});
|
||||
});
|
||||
|
||||
|
||||
it('should be displayed properly', function() {
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
tab;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define([
|
||||
'jquery', 'underscore', 'annotator_1.2.9', 'common/js/spec_helpers/ajax_helpers',
|
||||
'jquery', 'underscore', 'annotator_1.2.9', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'js/edxnotes/views/notes_visibility_factory', 'js/spec/edxnotes/helpers'
|
||||
], function(
|
||||
$, _, Annotator, AjaxHelpers, NotesVisibilityFactory, Helpers
|
||||
@@ -9,7 +9,7 @@ define([
|
||||
var params = {
|
||||
endpoint: '/test_endpoint',
|
||||
user: 'a user',
|
||||
usageId : 'an usage',
|
||||
usageId: 'an usage',
|
||||
courseId: 'a course',
|
||||
token: Helpers.makeToken(),
|
||||
tokenUrl: '/test_token_url'
|
||||
@@ -88,16 +88,17 @@ define([
|
||||
|
||||
it('can handle errors', function() {
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
errorContainer = $('.annotator-notice');
|
||||
$errorContainer = $('.annotator-notice');
|
||||
|
||||
this.button.click();
|
||||
AjaxHelpers.respondWithError(requests);
|
||||
expect(errorContainer).toContainText(
|
||||
"An error has occurred. Make sure that you are connected to the Internet, and then try refreshing the page."
|
||||
expect($errorContainer).toContainText(
|
||||
'An error has occurred. Make sure that you are connected to the Internet, ' +
|
||||
'and then try refreshing the page.'
|
||||
);
|
||||
expect(errorContainer).toBeVisible();
|
||||
expect(errorContainer).toHaveClass('annotator-notice-show');
|
||||
expect(errorContainer).toHaveClass('annotator-notice-error');
|
||||
expect($errorContainer).toBeVisible();
|
||||
expect($errorContainer).toHaveClass('annotator-notice-show');
|
||||
expect($errorContainer).toHaveClass('annotator-notice-error');
|
||||
|
||||
this.button.click();
|
||||
|
||||
@@ -112,10 +113,10 @@ define([
|
||||
AjaxHelpers.respondWithJson(requests, {});
|
||||
|
||||
AjaxHelpers.respondWithJson(requests, {});
|
||||
expect(errorContainer).not.toHaveClass('annotator-notice-show');
|
||||
expect($errorContainer).not.toHaveClass('annotator-notice-show');
|
||||
});
|
||||
|
||||
it('toggles notes when CTRL + SHIFT + [ keydown on document', function () {
|
||||
it('toggles notes when CTRL + SHIFT + [ keydown on document', function() {
|
||||
// Character '[' has keyCode 219
|
||||
$(document).trigger($.Event('keydown', {keyCode: 219, ctrlKey: true, shiftKey: true}));
|
||||
expect(this.toggleNotes.toggleHandler).toHaveBeenCalled();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'edx-ui-toolkit/js/utils/html-utils',
|
||||
'js/edxnotes/views/search_box',
|
||||
'js/edxnotes/collections/notes',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define([
|
||||
'jquery', 'common/js/spec_helpers/template_helpers', 'common/js/spec_helpers/ajax_helpers',
|
||||
'jquery', 'common/js/spec_helpers/template_helpers', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'js/edxnotes/collections/notes', 'js/edxnotes/collections/tabs', 'js/edxnotes/views/tabs/recent_activity',
|
||||
'js/spec/edxnotes/helpers'
|
||||
], function(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
define([
|
||||
'jquery', 'underscore', 'common/js/spec_helpers/template_helpers', 'common/js/spec_helpers/ajax_helpers',
|
||||
'jquery', 'underscore', 'common/js/spec_helpers/template_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'logger', 'js/edxnotes/collections/tabs', 'js/edxnotes/views/tabs/search_results',
|
||||
'js/spec/edxnotes/helpers'
|
||||
], function(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
define(['backbone', 'jquery', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
|
||||
define(['backbone', 'jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'js/groups/views/cohorts', 'js/groups/collections/cohort', 'js/groups/models/content_group',
|
||||
'js/groups/models/course_cohort_settings', 'js/utils/animation', 'js/vendor/jquery.qubit',
|
||||
'js/groups/views/course_cohort_settings_notification', 'js/groups/models/cohort_discussions',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*global define, sinon */
|
||||
define([
|
||||
'jquery',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'js/certificates/models/certificate_exception',
|
||||
'js/certificates/views/certificate_whitelist',
|
||||
'js/certificates/views/certificate_whitelist_editor',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*global define */
|
||||
define([
|
||||
'jquery',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'js/certificates/models/certificate_invalidation',
|
||||
'js/certificates/views/certificate_invalidation_view',
|
||||
'js/certificates/collections/certificate_invalidation_collection'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*global define, onCertificatesReady */
|
||||
define([
|
||||
'jquery',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'js/instructor_dashboard/certificates'
|
||||
],
|
||||
function($, AjaxHelpers) {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
/*global define */
|
||||
define(['jquery', 'coffee/src/instructor_dashboard/data_download', 'common/js/spec_helpers/ajax_helpers', 'slick.grid'],
|
||||
define(['jquery',
|
||||
'coffee/src/instructor_dashboard/data_download',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'slick.grid'],
|
||||
function ($, DataDownload, AjaxHelpers) {
|
||||
'use strict';
|
||||
describe("edx.instructor_dashboard.data_download.DataDownload_Certificate", function() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['jquery', 'coffee/src/instructor_dashboard/student_admin', 'common/js/spec_helpers/ajax_helpers'],
|
||||
define(['jquery', 'coffee/src/instructor_dashboard/student_admin', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers'],
|
||||
function ($, StudentAdmin, AjaxHelpers) {
|
||||
//'coffee/src/instructor_dashboard/student_admin'
|
||||
'use strict';
|
||||
|
||||
@@ -2,7 +2,7 @@ define([
|
||||
'jquery',
|
||||
'backbone',
|
||||
'logger',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/page_helpers',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'js/search/base/models/search_result',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['common/js/spec_helpers/ajax_helpers', 'js/shoppingcart/shoppingcart'],
|
||||
define(['edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'js/shoppingcart/shoppingcart'],
|
||||
function(AjaxHelpers) {
|
||||
'use strict';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ define([
|
||||
'backbone',
|
||||
'jquery',
|
||||
'js/staff_debug_actions',
|
||||
'common/js/spec_helpers/ajax_helpers'
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers'
|
||||
],
|
||||
function (Backbone, $, tmp, AjaxHelpers) {
|
||||
'use strict';
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'js/student_account/views/AccessView',
|
||||
'js/student_account/views/FormView',
|
||||
'js/student_account/enrollment',
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
|
||||
define(['backbone',
|
||||
'jquery',
|
||||
'underscore',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'js/spec/views/fields_helpers',
|
||||
'js/spec/student_account/helpers',
|
||||
'js/spec/student_account/account_settings_fields_helpers',
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
|
||||
define(['backbone',
|
||||
'jquery',
|
||||
'underscore',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'js/spec/views/fields_helpers',
|
||||
'string_utils'],
|
||||
function (Backbone, $, _, AjaxHelpers, TemplateHelpers, FieldViewsSpecHelpers) {
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
|
||||
define(['backbone',
|
||||
'jquery',
|
||||
'underscore',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'js/views/fields',
|
||||
'js/spec/views/fields_helpers',
|
||||
'js/spec/student_account/account_settings_fields_helpers',
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
|
||||
define(['backbone',
|
||||
'jquery',
|
||||
'underscore',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'js/spec/student_account/helpers',
|
||||
'js/views/fields',
|
||||
'js/student_account/models/user_account_model',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/emailoptin'],
|
||||
define(['edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'js/student_account/emailoptin'],
|
||||
function( AjaxHelpers, EmailOptInInterface ) {
|
||||
'use strict';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/enrollment'],
|
||||
define(['edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'js/student_account/enrollment'],
|
||||
function( AjaxHelpers, EnrollmentInterface ) {
|
||||
'use strict';
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
'jquery',
|
||||
'jquery.url',
|
||||
'utility',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'js/student_account/views/FinishAuthView',
|
||||
'js/student_account/enrollment',
|
||||
'js/student_account/shoppingcart',
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
'jquery',
|
||||
'underscore',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'js/student_account/views/HintedLoginView'
|
||||
],
|
||||
function($, _, TemplateHelpers, AjaxHelpers, HintedLoginView) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
'underscore',
|
||||
'sinon',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'js/student_account/models/LoginModel',
|
||||
'js/student_account/views/LoginView',
|
||||
'js/student_account/models/PasswordResetModel'
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'js/student_account/logistration_factory'
|
||||
],
|
||||
function($, _, Backbone, TemplateHelpers, AjaxHelpers, LogistrationFactory) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
'jquery',
|
||||
'underscore',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'js/student_account/models/PasswordResetModel',
|
||||
'js/student_account/views/PasswordResetView'
|
||||
],
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
'jquery',
|
||||
'underscore',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'js/student_account/models/RegisterModel',
|
||||
'js/student_account/views/RegisterView'
|
||||
],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/shoppingcart'],
|
||||
define(['edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'js/student_account/shoppingcart'],
|
||||
function(AjaxHelpers, ShoppingCartInterface) {
|
||||
'use strict';
|
||||
|
||||
|
||||
@@ -3,18 +3,18 @@ define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'URI',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'edx-ui-toolkit/js/pagination/paging-collection',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'js/spec/student_profile/helpers',
|
||||
'js/student_profile/views/badge_list_container'
|
||||
],
|
||||
function (Backbone, $, _, URI, PagingCollection, AjaxHelpers, LearnerProfileHelpers, BadgeListContainer) {
|
||||
function(Backbone, $, _, URI, AjaxHelpers, PagingCollection, LearnerProfileHelpers, BadgeListContainer) {
|
||||
'use strict';
|
||||
describe('edx.user.BadgeListContainer', function () {
|
||||
|
||||
var view, requests;
|
||||
|
||||
var createView = function (requests, pageNum, badge_list_object) {
|
||||
var createView = function(requests, pageNum, badgeListObject) {
|
||||
var BadgeCollection = PagingCollection.extend({
|
||||
queryParams: {
|
||||
currentPage: 'current_page'
|
||||
@@ -23,15 +23,15 @@ define([
|
||||
var badgeCollection = new BadgeCollection();
|
||||
badgeCollection.url = '/api/badges/v1/assertions/user/staff/';
|
||||
var models = [];
|
||||
_.each(_.range(badge_list_object.count), function (idx) {
|
||||
_.each(_.range(badgeListObject.count), function (idx) {
|
||||
models.push(LearnerProfileHelpers.makeBadge(idx));
|
||||
});
|
||||
badge_list_object.results = models;
|
||||
badgeListObject.results = models;
|
||||
badgeCollection.setPage(pageNum);
|
||||
var request = AjaxHelpers.currentRequest(requests);
|
||||
var path = new URI(request.url).path();
|
||||
expect(path).toBe('/api/badges/v1/assertions/user/staff/');
|
||||
AjaxHelpers.respondWithJson(requests, badge_list_object);
|
||||
AjaxHelpers.respondWithJson(requests, badgeListObject);
|
||||
var badgeListContainer = new BadgeListContainer({
|
||||
'collection': badgeCollection
|
||||
|
||||
@@ -92,4 +92,3 @@ define([
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['underscore', 'URI', 'common/js/spec_helpers/ajax_helpers'], function(_, URI, AjaxHelpers) {
|
||||
define(['underscore', 'URI', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers'], function(_, URI, AjaxHelpers) {
|
||||
'use strict';
|
||||
|
||||
var expectProfileElementContainsField = function(element, view) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers',
|
||||
define(['backbone', 'jquery', 'underscore', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'js/spec/student_account/helpers',
|
||||
'js/spec/student_profile/helpers',
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'common/js/spec_helpers/template_helpers',
|
||||
define(['backbone',
|
||||
'jquery',
|
||||
'underscore',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'js/spec/student_account/helpers',
|
||||
'js/student_account/models/user_account_model',
|
||||
'js/student_profile/views/learner_profile_fields',
|
||||
|
||||
@@ -2,7 +2,7 @@ define(['backbone',
|
||||
'jquery',
|
||||
'underscore',
|
||||
'edx-ui-toolkit/js/pagination/paging-collection',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'js/spec/student_account/helpers',
|
||||
'js/spec/student_profile/helpers',
|
||||
|
||||
@@ -2,7 +2,7 @@ define([
|
||||
'jquery',
|
||||
'backbone',
|
||||
'common/js/spec_helpers/template_helpers',
|
||||
'common/js/spec_helpers/ajax_helpers',
|
||||
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
|
||||
'js/verify_student/views/image_input_view',
|
||||
'js/verify_student/models/verification_model'
|
||||
], function( $, Backbone, TemplateHelpers, AjaxHelpers, ImageInputView, VerificationModel ) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user