');
view = new CertificatesView({
el: $('.certificates-content')
diff --git a/lms/djangoapps/support/static/support/js/spec/views/enrollment_spec.js b/lms/djangoapps/support/static/support/js/spec/views/enrollment_spec.js
index f533f7aa38..e8e2532005 100644
--- a/lms/djangoapps/support/static/support/js/spec/views/enrollment_spec.js
+++ b/lms/djangoapps/support/static/support/js/spec/views/enrollment_spec.js
@@ -46,7 +46,7 @@ define([
it('re-renders itself when its collection changes', function () {
var requests = AjaxHelpers.requests(this);
enrollmentView = createEnrollmentView().render();
- spyOn(enrollmentView, 'render').andCallThrough();
+ spyOn(enrollmentView, 'render').and.callThrough();
AjaxHelpers.respondWithJson(requests, [EnrollmentHelpers.mockEnrollmentData]);
expect(enrollmentView.render).toHaveBeenCalled();
});
diff --git a/lms/djangoapps/teams/static/teams/js/spec/views/edit_team_spec.js b/lms/djangoapps/teams/static/teams/js/spec/views/edit_team_spec.js
index 70f0e59e82..484ab5f476 100644
--- a/lms/djangoapps/teams/static/teams/js/spec/views/edit_team_spec.js
+++ b/lms/djangoapps/teams/static/teams/js/spec/views/edit_team_spec.js
@@ -140,7 +140,7 @@ define([
AjaxHelpers.respondWithJson(requests, _.extend({}, teamsData, teamAction === 'create' ? {id: '123'} : {}));
expect(teamEditView.$('.create-team.wrapper-msg .copy').text().trim().length).toBe(0);
- expect(Backbone.history.navigate.calls[0].args).toContain(expectedUrl);
+ expect(Backbone.history.navigate.calls.mostRecent().args[0]).toBe(expectedUrl);
};
var assertValidationMessagesWhenFieldsEmpty = function(that) {
@@ -217,7 +217,7 @@ define([
var assertRedirectsToCorrectUrlOnCancel = function(expectedUrl) {
var teamEditView = createEditTeamView();
teamEditView.$('.create-team.form-actions .action-cancel').click();
- expect(Backbone.history.navigate.calls[0].args).toContain(expectedUrl);
+ expect(Backbone.history.navigate.calls.mostRecent().args[0]).toBe(expectedUrl);
};
describe('NewTeam', function () {
diff --git a/lms/djangoapps/teams/static/teams/js/spec/views/team_profile_header_actions_spec.js b/lms/djangoapps/teams/static/teams/js/spec/views/team_profile_header_actions_spec.js
index 5f50e216e1..74befb6b90 100644
--- a/lms/djangoapps/teams/static/teams/js/spec/views/team_profile_header_actions_spec.js
+++ b/lms/djangoapps/teams/static/teams/js/spec/views/team_profile_header_actions_spec.js
@@ -250,7 +250,7 @@ define([
expect(editButton.length).toEqual(1);
$(editButton).click();
- expect(Backbone.history.navigate.calls[0].args[0]).toContain('/edit-team');
+ expect(Backbone.history.navigate.calls.mostRecent().args[0]).toContain('/edit-team');
});
});
});
diff --git a/lms/djangoapps/teams/static/teams/js/spec/views/topic_teams_spec.js b/lms/djangoapps/teams/static/teams/js/spec/views/topic_teams_spec.js
index 28edf5768b..9fc7f3f52a 100644
--- a/lms/djangoapps/teams/static/teams/js/spec/views/topic_teams_spec.js
+++ b/lms/djangoapps/teams/static/teams/js/spec/views/topic_teams_spec.js
@@ -65,12 +65,12 @@ define([
var teamsView = createTopicTeamsView();
spyOn(Backbone.history, 'navigate');
teamsView.$('.browse-teams').click();
- expect(Backbone.history.navigate.calls[0].args).toContain('browse');
+ expect(Backbone.history.navigate.calls.mostRecent().args[0]).toBe('browse');
});
it('gives the search field focus when clicking on the search teams link', function () {
var teamsView = createTopicTeamsView();
- spyOn($.fn, 'focus').andCallThrough();
+ spyOn($.fn, 'focus').and.callThrough();
teamsView.$('.search-teams').click();
expect(teamsView.$('.search-field').first().focus).toHaveBeenCalled();
});
@@ -79,7 +79,7 @@ define([
var teamsView = createTopicTeamsView();
spyOn(Backbone.history, 'navigate');
teamsView.$('a.create-team').click();
- expect(Backbone.history.navigate.calls[0].args).toContain(
+ expect(Backbone.history.navigate.calls.mostRecent().args[0]).toBe(
'topics/' + TeamSpecHelpers.testTopicID + '/create-team'
);
});
diff --git a/lms/static/coffee/spec/calculator_spec.coffee b/lms/static/coffee/spec/calculator_spec.coffee
index 3bd7fdc37a..40e4e646f5 100644
--- a/lms/static/coffee/spec/calculator_spec.coffee
+++ b/lms/static/coffee/spec/calculator_spec.coffee
@@ -37,19 +37,25 @@ describe 'Calculator', ->
$('form#calculator').submit()
describe 'toggle', ->
- it 'focuses the input when toggled', ->
+ it 'focuses the input when toggled', (done)->
- # Since the focus is called asynchronously, we need to
- # wait until focus() is called.
- didFocus = false
- runs ->
- spyOn($.fn, 'focus').andCallFake (elementName) -> didFocus = true
- @calculator.toggle(jQuery.Event("click"))
+ self = this
+ focus = ()->
+ deferred = $.Deferred()
- waitsFor (-> didFocus), "focus() should have been called on the input", 1000
+ # Since the focus is called asynchronously, we need to
+ # wait until focus() is called.
+ spyOn($.fn, 'focus').and.callFake (elementName) ->
+ deferred.resolve()
- runs ->
- expect($('#calculator_wrapper #calculator_input').focus).toHaveBeenCalled()
+ self.calculator.toggle(jQuery.Event("click"))
+
+ deferred.promise()
+
+ focus().then(
+ ->
+ expect($('#calculator_wrapper #calculator_input').focus).toHaveBeenCalled()
+ ).always(done)
it 'toggle the close button on the calculator button', ->
@calculator.toggle(jQuery.Event("click"))
@@ -305,10 +311,10 @@ describe 'Calculator', ->
'prevHint': calc
$.each(cases, (key, data) ->
- calc.hideHint.reset()
- calc.prevHint.reset()
- calc.nextHint.reset()
- $.fn.focus.reset()
+ calc.hideHint.calls.reset()
+ calc.prevHint.calls.reset()
+ calc.nextHint.calls.reset()
+ $.fn.focus.calls.reset()
e = jQuery.Event('keydown', data.event or {});
value = calc.handleKeyDownOnHint(e)
@@ -334,7 +340,7 @@ describe 'Calculator', ->
describe 'calculate', ->
beforeEach ->
$('#calculator_input').val '1+2'
- spyOn($, 'getWithPrefix').andCallFake (url, data, callback) ->
+ spyOn($, 'getWithPrefix').and.callFake (url, data, callback) ->
callback({ result: 3 })
@calculator.calculate()
diff --git a/lms/static/coffee/spec/feedback_form_spec.coffee b/lms/static/coffee/spec/feedback_form_spec.coffee
index 2083ddeebb..f4bc900bf4 100644
--- a/lms/static/coffee/spec/feedback_form_spec.coffee
+++ b/lms/static/coffee/spec/feedback_form_spec.coffee
@@ -5,7 +5,7 @@ describe 'FeedbackForm', ->
describe 'constructor', ->
beforeEach ->
new FeedbackForm
- spyOn($, 'postWithPrefix').andCallFake (url, data, callback, format) ->
+ spyOn($, 'postWithPrefix').and.callFake (url, data, callback, format) ->
callback()
it 'binds to the #feedback_button', ->
diff --git a/lms/static/coffee/spec/helper.coffee b/lms/static/coffee/spec/helper.coffee
index e9e4557e0c..0595362cec 100644
--- a/lms/static/coffee/spec/helper.coffee
+++ b/lms/static/coffee/spec/helper.coffee
@@ -13,7 +13,7 @@ jasmine.stubbedCaption =
text: ['Caption at 0', 'Caption at 10000', 'Caption at 20000', 'Caption at 30000']
jasmine.stubRequests = ->
- spyOn($, 'ajax').andCallFake (settings) ->
+ spyOn($, 'ajax').and.callFake (settings) ->
if match = settings.url.match /youtube\.com\/.+\/videos\/(.+)\?v=2&alt=jsonc/
settings.success data: jasmine.stubbedMetadata[match[1]]
else if match = settings.url.match /static\/subs\/(.+)\.srt\.sjson/
@@ -52,8 +52,6 @@ jasmine.stubVideoPlayer = (context, enableParts, createPlayer=true) ->
if createPlayer
return new VideoPlayer(video: context.video)
-spyOn(window, 'onunload')
-
# Stub Youtube API
window.YT =
PlayerState:
@@ -65,7 +63,7 @@ window.YT =
CUED: 5
# Stub jQuery.cookie
-$.cookie = jasmine.createSpy('jQuery.cookie').andReturn '1.0'
+$.cookie = jasmine.createSpy('jQuery.cookie').and.returnValue '1.0'
# Stub jQuery.qtip
$.fn.qtip = jasmine.createSpy 'jQuery.qtip'
diff --git a/lms/static/coffee/spec/histogram_spec.coffee b/lms/static/coffee/spec/histogram_spec.coffee
index 7a377221b3..9616b37223 100644
--- a/lms/static/coffee/spec/histogram_spec.coffee
+++ b/lms/static/coffee/spec/histogram_spec.coffee
@@ -25,7 +25,13 @@ describe 'Histogram', ->
describe 'render', ->
it 'call flot with correct option', ->
new Histogram(1, [[1, 1], [2, 2], [3, 3]])
- expect($.plot).toHaveBeenCalledWith $("#histogram_1"), [
+
+ firstArg = $.plot.calls.mostRecent().args[0]
+ secondArg = $.plot.calls.mostRecent().args[1]
+ thirdArg = $.plot.calls.mostRecent().args[2]
+
+ expect(firstArg.selector).toEqual($("#histogram_1").selector)
+ expect(secondArg).toEqual([
data: [[1, Math.log(2)], [2, Math.log(3)], [3, Math.log(4)]]
bars:
show: true
@@ -33,7 +39,8 @@ describe 'Histogram', ->
lineWidth: 0
fill: 1.0
color: "#b72121"
- ],
+ ])
+ expect(thirdArg).toEqual(
xaxis:
min: -1
max: 4
@@ -44,3 +51,4 @@ describe 'Histogram', ->
max: Math.log(4) * 1.1
ticks: [[Math.log(2), '1'], [Math.log(3), '2'], [Math.log(4), '3']]
labelWidth: 50
+ )
diff --git a/lms/static/coffee/spec/instructor_dashboard/membership_spec.coffee b/lms/static/coffee/spec/instructor_dashboard/membership_spec.coffee
index 28faf3e2e6..185f371855 100644
--- a/lms/static/coffee/spec/instructor_dashboard/membership_spec.coffee
+++ b/lms/static/coffee/spec/instructor_dashboard/membership_spec.coffee
@@ -10,22 +10,22 @@ describe 'AutoEnrollment', ->
expect(@autoenrollment.$browse_button).toHandle 'change'
it 'binds the ajax call and the result will be success', ->
- spyOn($, "ajax").andCallFake((params) =>
+ spyOn($, "ajax").and.callFake((params) =>
params.success({row_errors: [], general_errors: [], warnings: []})
{always: ->}
)
# mock the render_notification_view which returns the html (since we are only using the existing notification model)
- @autoenrollment.render_notification_view = jasmine.createSpy("render_notification_view(type, title, message, details) spy").andCallFake =>
+ @autoenrollment.render_notification_view = jasmine.createSpy("render_notification_view(type, title, message, details) spy").and.callFake =>
return '
Success
All accounts were created successfully.
'
- submitCallback = jasmine.createSpy().andReturn()
+ submitCallback = jasmine.createSpy().and.returnValue()
@autoenrollment.$student_enrollment_form.submit(submitCallback)
@autoenrollment.$enrollment_signup_button.click()
expect($('.results .message-copy').text()).toEqual('All accounts were created successfully.')
expect(submitCallback).toHaveBeenCalled()
it 'binds the ajax call and the result will be error', ->
- spyOn($, "ajax").andCallFake((params) =>
+ spyOn($, "ajax").and.callFake((params) =>
params.success({
row_errors: [{
'username': 'testuser1',
@@ -40,17 +40,17 @@ describe 'AutoEnrollment', ->
{always: ->}
)
# mock the render_notification_view which returns the html (since we are only using the existing notification model)
- @autoenrollment.render_notification_view = jasmine.createSpy("render_notification_view(type, title, message, details) spy").andCallFake =>
+ @autoenrollment.render_notification_view = jasmine.createSpy("render_notification_view(type, title, message, details) spy").and.callFake =>
return '
'
- submitCallback = jasmine.createSpy().andReturn()
+ submitCallback = jasmine.createSpy().and.returnValue()
@autoenrollment.$student_enrollment_form.submit(submitCallback)
@autoenrollment.$enrollment_signup_button.click()
expect($('.results .list-summary').text()).toEqual('cannot read the line 2testuser1 (testemail1@email.com): (Username already exists)');
expect(submitCallback).toHaveBeenCalled()
it 'binds the ajax call and the result will be warnings', ->
- spyOn($, "ajax").andCallFake((params) =>
+ spyOn($, "ajax").and.callFake((params) =>
params.success({
row_errors: [],
general_errors: [],
@@ -63,10 +63,10 @@ describe 'AutoEnrollment', ->
{always: ->}
)
# mock the render_notification_view which returns the html (since we are only using the existing notification model)
- @autoenrollment.render_notification_view = jasmine.createSpy("render_notification_view(type, title, message, details) spy").andCallFake =>
+ @autoenrollment.render_notification_view = jasmine.createSpy("render_notification_view(type, title, message, details) spy").and.callFake =>
return '
Warnings
The following warnings were generated:
user1 (user1email): (email is in valid)
'
- submitCallback = jasmine.createSpy().andReturn()
+ submitCallback = jasmine.createSpy().and.returnValue()
@autoenrollment.$student_enrollment_form.submit(submitCallback)
@autoenrollment.$enrollment_signup_button.click()
expect($('.results .list-summary').text()).toEqual('user1 (user1email): (email is in valid)')
diff --git a/lms/static/coffee/spec/requirejs_spec.coffee b/lms/static/coffee/spec/requirejs_spec.coffee
index 2ecbc8959d..369904f683 100644
--- a/lms/static/coffee/spec/requirejs_spec.coffee
+++ b/lms/static/coffee/spec/requirejs_spec.coffee
@@ -3,15 +3,30 @@ describe "RequireJS namespacing", ->
# Jasmine does not provide a way to use the typeof operator. We need
# to create our own custom matchers so that a TypeError is not thrown.
- @addMatchers
+ jasmine.addMatchers
requirejsTobeUndefined: ->
- typeof requirejs is "undefined"
+ {
+ compare: ->
+ {
+ pass: typeof requirejs is "undefined"
+ }
+ }
requireTobeUndefined: ->
- typeof require is "undefined"
+ {
+ compare: ->
+ {
+ pass: typeof require is "undefined"
+ }
+ }
defineTobeUndefined: ->
- typeof define is "undefined"
+ {
+ compare: ->
+ {
+ pass: typeof define is "undefined"
+ }
+ }
it "check that the RequireJS object is present in the global namespace", ->
@@ -34,12 +49,13 @@ describe "RequireJS namespacing", ->
describe "RequireJS module creation", ->
inDefineCallback = undefined
inRequireCallback = undefined
- it "check that we can use RequireJS to define() and require() a module", ->
-
+ it "check that we can use RequireJS to define() and require() a module", (done) ->
+ d1 = $.Deferred()
+ d2 = $.Deferred()
# Because Require JS works asynchronously when defining and requiring
# modules, we need to use the special Jasmine functions runs(), and
# waitsFor() to set up this test.
- runs ->
+ func = () ->
# Initialize the variable that we will test for. They will be set
# to true in the appropriate callback functions called by Require
@@ -52,6 +68,8 @@ describe "RequireJS module creation", ->
RequireJS.define "test_module", [], ->
inDefineCallback = true
+ d1.resolve()
+
# This module returns an object. It can be accessed via the
# Require JS require() function.
module_status: "OK"
@@ -66,24 +84,12 @@ describe "RequireJS module creation", ->
# property.
expect(test_module.module_status).toBe "OK"
+ d2.resolve()
-
- # We will wait for a specified amount of time (1 second), before
- # checking if our module was defined and that we were able to
- # require() the module.
- waitsFor (->
-
- # If at least one of the callback functions was not reached, we
- # fail this test.
- return false if (inDefineCallback isnt true) or (inRequireCallback isnt true)
-
- # Both of the callbacks were reached.
- true
- ), "We should eventually end up in the defined callback", 1000
-
- # The final test behavior, after waitsFor() finishes waiting.
- runs ->
+ func()
+ # We will wait before checking if our module was defined and that we were able to require() the module.
+ $.when(d1, d2).done(->
+ # The final test behavior
expect(inDefineCallback).toBeTruthy()
expect(inRequireCallback).toBeTruthy()
-
-
+ ).always(done)
diff --git a/lms/static/coffee/src/calculator.coffee b/lms/static/coffee/src/calculator.coffee
index 3342aee9dd..dd8c02f50c 100644
--- a/lms/static/coffee/src/calculator.coffee
+++ b/lms/static/coffee/src/calculator.coffee
@@ -62,7 +62,7 @@ class @Calculator
isExpanded = true
$calcWrapper
- .find('input, a,')
+ .find('input, a')
.attr 'tabindex', 0
# TODO: Investigate why doing this without the timeout causes it to jump
# down to the bottom of the page. I suspect it's because it's putting the
diff --git a/lms/static/js/spec/bookmarks/bookmark_button_view_spec.js b/lms/static/js/spec/bookmarks/bookmark_button_view_spec.js
index a8f00f0acf..9dc0950a1a 100644
--- a/lms/static/js/spec/bookmarks/bookmark_button_view_spec.js
+++ b/lms/static/js/spec/bookmarks/bookmark_button_view_spec.js
@@ -18,7 +18,11 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
);
timerCallback = jasmine.createSpy('timerCallback');
- jasmine.Clock.useMock();
+ jasmine.clock().install();
+ });
+
+ afterEach(function() {
+ jasmine.clock().uninstall();
});
var createBookmarkButtonView = function(isBookmarked) {
@@ -80,7 +84,7 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
var bookmarkButtonView = createBookmarkButtonView(firstActionData.bookmarked);
verifyBookmarkButtonState(bookmarkButtonView, firstActionData.bookmarked);
- spyOn(bookmarkButtonView, firstActionData.handler).andCallThrough();
+ spyOn(bookmarkButtonView, firstActionData.handler).and.callThrough();
spyOnEvent(bookmarkButtonView.$el, firstActionData.event);
bookmarkButtonView.$el.click();
@@ -96,12 +100,12 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
expect(bookmarkButtonView[firstActionData.handler]).toHaveBeenCalled();
AjaxHelpers.respondWithJson(requests, {});
expect(firstActionData.event).toHaveBeenTriggeredOn(bookmarkButtonView.$el);
- bookmarkButtonView[firstActionData.handler].reset();
+ bookmarkButtonView[firstActionData.handler].calls.reset();
expect(bookmarkButtonView.$el).not.toHaveAttr('disabled');
verifyBookmarkButtonState(bookmarkButtonView, secondActionData.bookmarked);
- spyOn(bookmarkButtonView, secondActionData.handler).andCallThrough();
+ spyOn(bookmarkButtonView, secondActionData.handler).and.callThrough();
spyOnEvent(bookmarkButtonView.$el, secondActionData.event);
bookmarkButtonView.$el.click();
@@ -154,7 +158,7 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
expect($messageBanner.text().trim()).toBe(bookmarkButtonView.errorMessage);
- jasmine.Clock.tick(5001);
+ jasmine.clock().tick(5001);
expect($messageBanner.text().trim()).toBe('');
});
});
diff --git a/lms/static/js/spec/bookmarks/bookmarks_list_view_spec.js b/lms/static/js/spec/bookmarks/bookmarks_list_view_spec.js
index ab356d348a..2a75e723f1 100644
--- a/lms/static/js/spec/bookmarks/bookmarks_list_view_spec.js
+++ b/lms/static/js/spec/bookmarks/bookmarks_list_view_spec.js
@@ -24,10 +24,16 @@ define(['backbone',
'templates/bookmarks/bookmarks-list'
]
);
- spyOn(Logger, 'log').andReturn($.Deferred().resolve());
- this.addMatchers({
- toHaveBeenCalledWithUrl: function (expectedUrl) {
- return expectedUrl === this.actual.argsForCall[0][0].target.pathname;
+ spyOn(Logger, 'log').and.returnValue($.Deferred().resolve());
+ jasmine.addMatchers({
+ toHaveBeenCalledWithUrl: function () {
+ return {
+ compare: function (actual, expectedUrl) {
+ return {
+ pass: expectedUrl === actual.calls.mostRecent().args[0].currentTarget.pathname
+ };
+ }
+ };
}
});
@@ -117,7 +123,7 @@ define(['backbone',
it("has correct behavior for bookmarks button", function () {
var requests = AjaxHelpers.requests(this);
- spyOn(bookmarksButtonView, 'toggleBookmarksListView').andCallThrough();
+ spyOn(bookmarksButtonView, 'toggleBookmarksListView').and.callThrough();
bookmarksButtonView.delegateEvents();
diff --git a/lms/static/js/spec/ccx/schedule_spec.js b/lms/static/js/spec/ccx/schedule_spec.js
index 9dd6e4fa08..231b4fed18 100644
--- a/lms/static/js/spec/ccx/schedule_spec.js
+++ b/lms/static/js/spec/ccx/schedule_spec.js
@@ -2,18 +2,21 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/ccx/schedule'],
function(AjaxHelpers) {
describe("edx.ccx.schedule.ScheduleView", function() {
var view = null;
+ var data;
beforeEach(function() {
loadFixtures("js/fixtures/ccx/schedule.html");
var scheduleFixture = readFixtures("templates/ccx/schedule.underscore");
- appendSetFixtures("
" + scheduleFixture + "
");
+ appendSetFixtures(
+ ""
+ );
schedule_template = _.template($('#schedule_template').html());
save_url = 'save_ccx';
$.fn.leanModal = function(param) {
return true;
- }
+ };
data = [{
"category": "chapter",
@@ -44,10 +47,8 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/ccx/schedule'],
]
}];
view = new edx.ccx.schedule.ScheduleView({el: $('#new-ccx-schedule')});
- view.schedule_collection.set(data)
+ view.schedule_collection.set(data);
view.render();
-
-
});
it("verifies correct view setup", function() {
diff --git a/lms/static/js/spec/dashboard/donation.js b/lms/static/js/spec/dashboard/donation.js
index b6a90955c5..55447995ef 100644
--- a/lms/static/js/spec/dashboard/donation.js
+++ b/lms/static/js/spec/dashboard/donation.js
@@ -29,7 +29,7 @@ define(['common/js/spec_helpers/template_helpers', 'common/js/spec_helpers/ajax_
// This function gets passed the dynamically constructed
// form with signed payment parameters from the LMS server,
// so we can verify that the form is constructed correctly.
- spyOn(view, 'submitPaymentForm').andCallFake(function() {});
+ spyOn(view, 'submitPaymentForm').and.callFake(function() {});
// Stub the analytics event tracker
window.analytics = jasmine.createSpyObj('analytics', ['track']);
@@ -64,7 +64,7 @@ define(['common/js/spec_helpers/template_helpers', 'common/js/spec_helpers/ajax_
// We stub out the actual submission of the form to avoid
// leaving the current page during the test.
expect(view.submitPaymentForm).toHaveBeenCalled();
- var form = view.submitPaymentForm.mostRecentCall.args[0];
+ var form = view.submitPaymentForm.calls.mostRecent().args[0];
expect(form.serialize()).toEqual($.param(PAYMENT_PARAMS));
expect(form.attr('method')).toEqual("post");
expect(form.attr('action')).toEqual(PAYMENT_URL);
diff --git a/lms/static/js/spec/dashboard/dropdown_spec.js b/lms/static/js/spec/dashboard/dropdown_spec.js
index 2b9b18177c..b3b63a3a5a 100644
--- a/lms/static/js/spec/dashboard/dropdown_spec.js
+++ b/lms/static/js/spec/dashboard/dropdown_spec.js
@@ -14,15 +14,10 @@ define(['js/dashboard/dropdown', 'jquery.simulate'],
verifyDropdownNotVisible = function() {
expect($(dropdownSelector)).not.toBeVisible();
},
- waitForElementToBeFocused = function(element, desc) {
- // This is being used instead of toBeFocused which is flaky
- waitsFor(
- function () {
- return element === document.activeElement;
- },
- desc + ' element to have focus',
- 500
- );
+ waitForElementToBeFocused = function(element, done) {
+ jasmine.waitUntil(function () {
+ return element === document.activeElement;
+ }).always(done);
},
openDropDownMenu = function() {
verifyDropdownNotVisible();
@@ -47,39 +42,39 @@ define(['js/dashboard/dropdown', 'jquery.simulate'],
clickToggleButton();
verifyDropdownNotVisible();
});
- it("ESCAPE will close dropdown and return focus to the button", function() {
+ it("ESCAPE will close dropdown and return focus to the button", function(done) {
openDropDownMenu();
keydown({ keyCode: keys.ESCAPE });
verifyDropdownNotVisible();
- waitForElementToBeFocused($(toggleButtonSelector)[0], "button");
+ waitForElementToBeFocused($(toggleButtonSelector)[0], done);
});
- it("SPACE will close dropdown and return focus to the button", function() {
+ it("SPACE will close dropdown and return focus to the button", function(done) {
openDropDownMenu();
keydown({ keyCode: keys.SPACE });
verifyDropdownNotVisible();
- waitForElementToBeFocused($(toggleButtonSelector)[0], "button");
+ waitForElementToBeFocused($(toggleButtonSelector)[0], done);
});
describe("Focus is trapped when navigating with", function() {
- it("TAB key", function() {
+ it("TAB key", function(done) {
openDropDownMenu();
keydown({ keyCode: keys.TAB });
- waitForElementToBeFocused($(dropdownItemSelector)[0], "first");
+ waitForElementToBeFocused($(dropdownItemSelector)[0], done);
});
- it("DOWN key", function() {
+ it("DOWN key", function(done) {
openDropDownMenu();
keydown({ keyCode: keys.DOWN });
- waitForElementToBeFocused($(dropdownItemSelector)[0], "first");
+ waitForElementToBeFocused($(dropdownItemSelector)[0], done);
});
- it("TAB key + SHIFT key", function() {
+ it("TAB key + SHIFT key", function(done) {
openDropDownMenu();
keydown({ keyCode: keys.TAB, shiftKey: true });
- waitForElementToBeFocused($(dropdownItemSelector)[1], "last");
+ waitForElementToBeFocused($(dropdownItemSelector)[1], done);
});
- it("UP key", function() {
+ it("UP key", function(done) {
openDropDownMenu();
keydown({ keyCode: keys.UP });
- waitForElementToBeFocused($(dropdownItemSelector)[1], "last");
+ waitForElementToBeFocused($(dropdownItemSelector)[1], done);
});
});
});
diff --git a/lms/static/js/spec/discovery/discovery_factory_spec.js b/lms/static/js/spec/discovery/discovery_factory_spec.js
index 199323d0ea..2395895946 100644
--- a/lms/static/js/spec/discovery/discovery_factory_spec.js
+++ b/lms/static/js/spec/discovery/discovery_factory_spec.js
@@ -121,7 +121,7 @@ define([
it('loads more', function () {
var requests = AjaxHelpers.requests(this);
- jasmine.Clock.useMock();
+ jasmine.clock().install();
$('.discovery-input').val('test');
$('.discovery-submit').trigger('click');
AjaxHelpers.respondWithJson(requests, JSON_RESPONSE);
@@ -129,12 +129,14 @@ define([
expect($('.courses-listing .course-title')).toContainHtml('edX Demonstration Course');
window.scroll(0, $(document).height());
$(window).trigger('scroll');
- jasmine.Clock.tick(500);
+ jasmine.clock().tick(500);
// TODO: determine why the search API is invoked twice
AjaxHelpers.respondWithJson(requests, JSON_RESPONSE);
AjaxHelpers.respondWithJson(requests, JSON_RESPONSE);
expect($('.courses-listing article').length).toEqual(2);
+
+ jasmine.clock().uninstall();
});
it('displays not found message', function () {
diff --git a/lms/static/js/spec/discovery/views/course_card_spec.js b/lms/static/js/spec/discovery/views/course_card_spec.js
index 2e3c71c17a..97f49a09c2 100644
--- a/lms/static/js/spec/discovery/views/course_card_spec.js
+++ b/lms/static/js/spec/discovery/views/course_card_spec.js
@@ -43,8 +43,8 @@ define([
it('renders', function () {
var data = this.view.model.attributes;
expect(this.view.$el).toContainHtml(data.content.display_name);
- expect(this.view.$el).toContain('a[href="/courses/' + data.course + '/about"]');
- expect(this.view.$el).toContain('img[src="' + data.image_url + '"]');
+ expect(this.view.$el).toContainElement('a[href="/courses/' + data.course + '/about"]');
+ expect(this.view.$el).toContainElement('img[src="' + data.image_url + '"]');
expect(this.view.$el.find('.course-name')).toContainHtml(data.org);
expect(this.view.$el.find('.course-name')).toContainHtml(data.content.number);
expect(this.view.$el.find('.course-name')).toContainHtml(data.content.display_name);
diff --git a/lms/static/js/spec/discovery/views/courses_listing_spec.js b/lms/static/js/spec/discovery/views/courses_listing_spec.js
index 2bd4d38b76..0001561773 100644
--- a/lms/static/js/spec/discovery/views/courses_listing_spec.js
+++ b/lms/static/js/spec/discovery/views/courses_listing_spec.js
@@ -34,7 +34,7 @@ define([
describe('discovery.views.CoursesListing', function () {
beforeEach(function () {
- jasmine.Clock.useMock();
+ jasmine.clock().install();
loadFixtures('js/fixtures/discovery.html');
TemplateHelpers.installTemplate('templates/discovery/course_card');
var collection = new Backbone.Collection(
@@ -44,10 +44,14 @@ define([
var mock = {
collection: collection,
latest: function () { return this.collection.last(20); }
- }
+ };
this.view = new CoursesListing({ model: mock });
});
+ afterEach(function() {
+ jasmine.clock().uninstall();
+ });
+
it('renders search results', function () {
this.view.render();
expect($('.courses-listing article').length).toEqual(1);
@@ -62,13 +66,13 @@ define([
this.view.render();
window.scroll(0, $(document).height());
$(window).trigger('scroll');
- jasmine.Clock.tick(500);
+ jasmine.clock().tick(500);
expect(this.onNext).toHaveBeenCalled();
// should not be triggered again (while it is loading)
$(window).trigger('scroll');
- jasmine.Clock.tick(500);
- expect(this.onNext.calls.length).toEqual(1);
+ jasmine.clock().tick(500);
+ expect(this.onNext.calls.count()).toEqual(1);
});
});
diff --git a/lms/static/js/spec/edxnotes/custom_matchers.js b/lms/static/js/spec/edxnotes/custom_matchers.js
deleted file mode 100644
index c5309bd6c9..0000000000
--- a/lms/static/js/spec/edxnotes/custom_matchers.js
+++ /dev/null
@@ -1,32 +0,0 @@
-define(['jquery'], function($) {
- 'use strict';
- return function (that) {
- that.addMatchers({
- toContainText: function (text) {
- var trimmedText = $.trim($(this.actual).text());
-
- if (text && $.isFunction(text.test)) {
- return text.test(trimmedText);
- } else {
- return trimmedText.indexOf(text) !== -1;
- }
- },
-
- toHaveLength: function (number) {
- return $(this.actual).length === number;
- },
-
- toHaveIndex: function (number) {
- return $(this.actual).index() === number;
- },
-
- toBeInRange: function (min, max) {
- return min <= this.actual && this.actual <= max;
- },
-
- toBeFocused: function () {
- return $(this.actual)[0] === $(this.actual)[0].ownerDocument.activeElement;
- }
- });
- };
-});
diff --git a/lms/static/js/spec/edxnotes/plugins/accessibility_spec.js b/lms/static/js/spec/edxnotes/plugins/accessibility_spec.js
index f4128df9b7..e4abb6122a 100644
--- a/lms/static/js/spec/edxnotes/plugins/accessibility_spec.js
+++ b/lms/static/js/spec/edxnotes/plugins/accessibility_spec.js
@@ -1,6 +1,6 @@
define([
- 'jquery', 'underscore', 'annotator_1.2.9', 'logger', 'js/edxnotes/views/notes_factory', 'js/spec/edxnotes/custom_matchers'
-], function($, _, Annotator, Logger, NotesFactory, customMatchers) {
+ 'jquery', 'underscore', 'annotator_1.2.9', 'logger', 'js/edxnotes/views/notes_factory'
+], function($, _, Annotator, Logger, NotesFactory) {
'use strict';
describe('EdxNotes Accessibility Plugin', function() {
function keyDownEvent (key) {
@@ -25,7 +25,6 @@ define([
beforeEach(function() {
this.KEY = $.ui.keyCode;
- customMatchers(this);
loadFixtures('js/fixtures/edxnotes/edxnotes_wrapper.html');
this.annotator = NotesFactory.factory(
$('div#edx-notes-wrapper-123').get(0), {
@@ -45,7 +44,7 @@ define([
describe('destroy', function () {
it('should unbind all events', function () {
spyOn($.fn, 'off');
- spyOn(this.annotator, 'unsubscribe').andCallThrough();
+ spyOn(this.annotator, 'unsubscribe').and.callThrough();
this.plugin.destroy();
expect(this.annotator.unsubscribe).toHaveBeenCalledWith(
'annotationViewerTextField', this.plugin.addAriaAttributes
@@ -82,7 +81,7 @@ define([
this.annotator.viewer.load([annotation]);
note = $('.annotator-note');
expect(note).toExist();
- expect(note).toHaveAttr('tabindex', -1);
+ expect(note).toHaveAttr('tabindex', "-1");
expect(note).toHaveAttr('role', 'note');
expect(note).toHaveAttr('class', 'annotator-note');
});
@@ -116,9 +115,9 @@ define([
highlights: [highlight.get(0)]
};
highlight.data('annotation', annotation);
- spyOn(this.annotator, 'showViewer').andCallThrough();
- spyOn(this.annotator.viewer, 'hide').andCallThrough();
- spyOn(this.plugin, 'focusOnGrabber').andCallThrough();
+ spyOn(this.annotator, 'showViewer').and.callThrough();
+ spyOn(this.annotator.viewer, 'hide').and.callThrough();
+ spyOn(this.plugin, 'focusOnGrabber').and.callThrough();
});
it('should open the viewer on SPACE keydown and focus on note', function () {
@@ -175,7 +174,7 @@ define([
edit= this.annotator.element.find('.annotator-edit').first();
del = this.annotator.element.find('.annotator-delete').first();
close = this.annotator.element.find('.annotator-close').first();
- spyOn(this.annotator.viewer, 'hide').andCallThrough();
+ spyOn(this.annotator.viewer, 'hide').and.callThrough();
});
it('should give focus to Note on Listing TAB keydown', function () {
@@ -221,7 +220,7 @@ define([
control.focus();
control.trigger(keyDownEvent(this.KEY.ESCAPE));
}, this);
- expect(this.annotator.viewer.hide.callCount).toBe(5);
+ expect(this.annotator.viewer.hide.calls.count()).toBe(5);
});
});
@@ -243,8 +242,8 @@ define([
tags = annotatorItems.first().next().children('input');
save = this.annotator.element.find('.annotator-save');
cancel = this.annotator.element.find('.annotator-cancel');
- spyOn(this.annotator.editor, 'submit').andCallThrough();
- spyOn(this.annotator.editor, 'hide').andCallThrough();
+ spyOn(this.annotator.editor, 'submit').and.callThrough();
+ spyOn(this.annotator.editor, 'hide').and.callThrough();
});
it('should give focus to TextArea on Form TAB keydown', function () {
@@ -287,7 +286,7 @@ define([
save.focus();
save.trigger(keyDownEvent(this.KEY.ENTER));
expect(this.annotator.editor.submit).toHaveBeenCalled();
- this.annotator.editor.submit.reset();
+ this.annotator.editor.submit.calls.reset();
save.focus();
save.trigger(keyDownEvent(this.KEY.SPACE));
expect(this.annotator.editor.submit).toHaveBeenCalled();
@@ -297,7 +296,7 @@ define([
textArea.focus();
textArea.trigger(enterMetaKeyEvent());
expect(this.annotator.editor.submit).toHaveBeenCalled();
- this.annotator.editor.submit.reset();
+ this.annotator.editor.submit.calls.reset();
textArea.focus();
textArea.trigger(enterControlKeyEvent());
expect(this.annotator.editor.submit).toHaveBeenCalled();
@@ -307,7 +306,7 @@ define([
cancel.focus();
cancel.trigger(keyDownEvent(this.KEY.ENTER));
expect(this.annotator.editor.hide).toHaveBeenCalled();
- this.annotator.editor.hide.reset();
+ this.annotator.editor.hide.calls.reset();
cancel.focus();
save.trigger(keyDownEvent(this.KEY.SPACE));
expect(this.annotator.editor.hide).toHaveBeenCalled();
@@ -320,7 +319,7 @@ define([
control.focus();
control.trigger(keyDownEvent(this.KEY.ESCAPE));
}, this);
- expect(this.annotator.editor.hide.callCount).toBe(3);
+ expect(this.annotator.editor.hide.calls.count()).toBe(3);
});
});
});
diff --git a/lms/static/js/spec/edxnotes/plugins/caret_navigation_spec.js b/lms/static/js/spec/edxnotes/plugins/caret_navigation_spec.js
index 4bd20371bf..544b6881a3 100644
--- a/lms/static/js/spec/edxnotes/plugins/caret_navigation_spec.js
+++ b/lms/static/js/spec/edxnotes/plugins/caret_navigation_spec.js
@@ -87,10 +87,10 @@ define([
this.mockSubscriber = jasmine.createSpy();
this.annotator.subscribe('annotationCreated', this.mockSubscriber);
- spyOn($.fn, 'position').andReturn(this.mockOffset);
- spyOn(this.annotator, 'createAnnotation').andReturn(this.annotation);
- spyOn(this.annotator, 'setupAnnotation').andReturn(this.annotation);
- spyOn(this.annotator, 'getSelectedRanges').andReturn([{}]);
+ spyOn($.fn, 'position').and.returnValue(this.mockOffset);
+ spyOn(this.annotator, 'createAnnotation').and.returnValue(this.annotation);
+ spyOn(this.annotator, 'setupAnnotation').and.returnValue(this.annotation);
+ spyOn(this.annotator, 'getSelectedRanges').and.returnValue([{}]);
spyOn(this.annotator, 'deleteAnnotation');
spyOn(this.annotator, 'showEditor');
spyOn(Annotator.Util, 'readRangeViaSelection');
@@ -100,7 +100,7 @@ define([
it('should create a new annotation', function () {
triggerEvent(this.element);
- expect(this.annotator.createAnnotation.callCount).toBe(1);
+ expect(this.annotator.createAnnotation.calls.count()).toBe(1);
});
it('should set up the annotation', function () {
@@ -111,25 +111,25 @@ define([
});
it('should display the Annotation#editor correctly if the Annotation#adder is hidden', function () {
- spyOn($.fn, 'is').andReturn(false);
+ spyOn($.fn, 'is').and.returnValue(false);
triggerEvent(this.element);
- expect($('annotator-hl-temporary').position.callCount).toBe(1);
+ expect($('annotator-hl-temporary').position.calls.count()).toBe(1);
expect(this.annotator.showEditor).toHaveBeenCalledWith(
this.annotation, this.mockOffset
);
});
it('should display the Annotation#editor in the same place as the Annotation#adder', function () {
- spyOn($.fn, 'is').andReturn(true);
+ spyOn($.fn, 'is').and.returnValue(true);
triggerEvent(this.element);
- expect(this.annotator.adder.position.callCount).toBe(1);
+ expect(this.annotator.adder.position.calls.count()).toBe(1);
expect(this.annotator.showEditor).toHaveBeenCalledWith(
this.annotation, this.mockOffset
);
});
it('should hide the Annotation#adder', function () {
- spyOn($.fn, 'is').andReturn(true);
+ spyOn($.fn, 'is').and.returnValue(true);
spyOn($.fn, 'hide');
triggerEvent(this.element);
expect(this.annotator.adder.hide).toHaveBeenCalled();
@@ -187,13 +187,13 @@ define([
});
it('should do nothing if empty selection', function () {
- this.annotator.getSelectedRanges.andReturn([]);
+ this.annotator.getSelectedRanges.and.returnValue([]);
triggerEvent(this.element);
expect(this.annotator.showEditor).not.toHaveBeenCalled();
});
it('should do nothing if selection is in Annotator', function () {
- spyOn(this.annotator, 'isAnnotator').andReturn(true);
+ spyOn(this.annotator, 'isAnnotator').and.returnValue(true);
triggerEvent(this.element);
expect(this.annotator.showEditor).not.toHaveBeenCalled();
});
diff --git a/lms/static/js/spec/edxnotes/plugins/scroller_spec.js b/lms/static/js/spec/edxnotes/plugins/scroller_spec.js
index 77c1d7eeb2..49c54dda6c 100644
--- a/lms/static/js/spec/edxnotes/plugins/scroller_spec.js
+++ b/lms/static/js/spec/edxnotes/plugins/scroller_spec.js
@@ -1,7 +1,6 @@
define([
- 'jquery', 'underscore', 'annotator_1.2.9', 'js/edxnotes/views/notes_factory',
- 'js/spec/edxnotes/custom_matchers'
-], function($, _, Annotator, NotesFactory, customMatchers) {
+ 'jquery', 'underscore', 'annotator_1.2.9', 'js/edxnotes/views/notes_factory'
+], function($, _, Annotator, NotesFactory) {
'use strict';
describe('EdxNotes Scroll Plugin', function() {
var annotators, highlights;
@@ -19,7 +18,6 @@ define([
}
beforeEach(function() {
- customMatchers(this);
loadFixtures('js/fixtures/edxnotes/edxnotes_wrapper.html');
annotators = [
NotesFactory.factory($('div#edx-notes-wrapper-123').get(0), {
@@ -31,9 +29,9 @@ define([
];
highlights = _.map(annotators, function(annotator) {
- spyOn(annotator, 'onHighlightClick').andCallThrough();
- spyOn(annotator, 'onHighlightMouseover').andCallThrough();
- spyOn(annotator, 'startViewerHideTimer').andCallThrough();
+ spyOn(annotator, 'onHighlightClick').and.callThrough();
+ spyOn(annotator, 'onHighlightMouseover').and.callThrough();
+ spyOn(annotator, 'startViewerHideTimer').and.callThrough();
return $('', {
'class': 'annotator-hl',
'tabindex': -1,
@@ -41,8 +39,8 @@ define([
}).appendTo(annotator.element);
});
- spyOn(annotators[0].plugins.Scroller, 'getIdFromLocationHash').andReturn('abc123');
- spyOn($.fn, 'unbind').andCallThrough();
+ spyOn(annotators[0].plugins.Scroller, 'getIdFromLocationHash').and.returnValue('abc123');
+ spyOn($.fn, 'unbind').and.callThrough();
});
afterEach(function () {
@@ -56,7 +54,7 @@ define([
id: 'abc123',
highlights: [highlights[0]]
}]);
- annotators[0].onHighlightMouseover.reset();
+ annotators[0].onHighlightMouseover.calls.reset();
expect(highlights[0]).toBeFocused();
highlights[0].mouseover();
highlights[0].mouseout();
diff --git a/lms/static/js/spec/edxnotes/utils/logger_spec.js b/lms/static/js/spec/edxnotes/utils/logger_spec.js
index a84bad0eac..802ec55e72 100644
--- a/lms/static/js/spec/edxnotes/utils/logger_spec.js
+++ b/lms/static/js/spec/edxnotes/utils/logger_spec.js
@@ -1,6 +1,6 @@
define([
- 'logger', 'js/edxnotes/utils/logger', 'js/spec/edxnotes/custom_matchers'
-], function(Logger, NotesLogger, customMatchers) {
+ 'logger', 'js/edxnotes/utils/logger'
+], function(Logger, NotesLogger) {
'use strict';
describe('Edxnotes NotesLogger', function() {
var getLogger = function(id, mode) {
@@ -11,7 +11,6 @@ define([
spyOn(window.console, 'log');
spyOn(window.console, 'error');
spyOn(Logger, 'log');
- customMatchers(this);
});
it('keeps a correct history of logs', function() {
@@ -94,11 +93,11 @@ define([
it('can use timers', function() {
var logger = getLogger('id', 1), logs, log;
- spyOn(performance, 'now').andReturn(1);
- spyOn(Date, 'now').andReturn(1);
+ spyOn(performance, 'now').and.returnValue(1);
+ spyOn(Date, 'now').and.returnValue(1);
logger.time('timer');
- performance.now.andReturn(201);
- Date.now.andReturn(201);
+ performance.now.and.returnValue(201);
+ Date.now.and.returnValue(201);
logger.timeEnd('timer');
logs = logger.getHistory();
diff --git a/lms/static/js/spec/edxnotes/views/note_item_spec.js b/lms/static/js/spec/edxnotes/views/note_item_spec.js
index 84ea75a39f..4b3a0af123 100644
--- a/lms/static/js/spec/edxnotes/views/note_item_spec.js
+++ b/lms/static/js/spec/edxnotes/views/note_item_spec.js
@@ -2,10 +2,8 @@ define([
'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers',
'common/js/spec_helpers/template_helpers', 'js/spec/edxnotes/helpers', 'logger',
'js/edxnotes/models/note', 'js/edxnotes/views/note_item',
- 'js/spec/edxnotes/custom_matchers'
], function(
- $, _, AjaxHelpers, TemplateHelpers, Helpers, Logger, NoteModel, NoteItemView,
- customMatchers
+ $, _, AjaxHelpers, TemplateHelpers, Helpers, Logger, NoteModel, NoteItemView
) {
'use strict';
describe('EdxNotes NoteItemView', function() {
@@ -27,16 +25,15 @@ define([
};
beforeEach(function() {
- customMatchers(this);
TemplateHelpers.installTemplate('templates/edxnotes/note-item');
- spyOn(Logger, 'log').andCallThrough();
+ spyOn(Logger, 'log').and.callThrough();
});
it('can be rendered properly', function() {
var view = getView(),
unitLink = view.$('.reference-unit-link').get(0);
- expect(view.$el).toContain('.note-excerpt-more-link');
+ expect(view.$el).toContainElement('.note-excerpt-more-link');
expect(view.$el).toContainText(Helpers.PRUNED_TEXT);
expect(view.$el).toContainText('More');
view.$('.note-excerpt-more-link').click();
diff --git a/lms/static/js/spec/edxnotes/views/notes_factory_spec.js b/lms/static/js/spec/edxnotes/views/notes_factory_spec.js
index dda98b8b59..0865da6ee0 100644
--- a/lms/static/js/spec/edxnotes/views/notes_factory_spec.js
+++ b/lms/static/js/spec/edxnotes/views/notes_factory_spec.js
@@ -1,11 +1,10 @@
define([
'annotator_1.2.9', 'js/edxnotes/views/notes_factory', 'common/js/spec_helpers/ajax_helpers',
- 'js/spec/edxnotes/helpers', 'js/spec/edxnotes/custom_matchers'
-], function(Annotator, NotesFactory, AjaxHelpers, Helpers, customMatchers) {
+ 'js/spec/edxnotes/helpers'
+], function(Annotator, NotesFactory, AjaxHelpers, Helpers) {
'use strict';
describe('EdxNotes NotesFactory', function() {
beforeEach(function() {
- customMatchers(this);
loadFixtures('js/fixtures/edxnotes/edxnotes_wrapper.html');
this.wrapper = document.getElementById('edx-notes-wrapper-123');
});
diff --git a/lms/static/js/spec/edxnotes/views/notes_page_spec.js b/lms/static/js/spec/edxnotes/views/notes_page_spec.js
index 2c2ad249bf..79388f9081 100644
--- a/lms/static/js/spec/edxnotes/views/notes_page_spec.js
+++ b/lms/static/js/spec/edxnotes/views/notes_page_spec.js
@@ -1,14 +1,13 @@
define([
'jquery', 'underscore', 'common/js/spec_helpers/template_helpers',
'common/js/spec_helpers/ajax_helpers', 'js/spec/edxnotes/helpers',
- 'js/edxnotes/views/page_factory', 'js/spec/edxnotes/custom_matchers'
-], function($, _, TemplateHelpers, AjaxHelpers, Helpers, NotesFactory, customMatchers) {
+ 'js/edxnotes/views/page_factory'
+], function($, _, TemplateHelpers, AjaxHelpers, Helpers, NotesFactory) {
'use strict';
describe('EdxNotes NotesPage', function() {
var notes = Helpers.getDefaultNotes();
beforeEach(function() {
- customMatchers(this);
loadFixtures('js/fixtures/edxnotes/edxnotes.html');
TemplateHelpers.installTemplates([
'templates/edxnotes/note-item', 'templates/edxnotes/tab-item'
diff --git a/lms/static/js/spec/edxnotes/views/notes_visibility_factory_spec.js b/lms/static/js/spec/edxnotes/views/notes_visibility_factory_spec.js
index cf2f3fa7ff..26e1db8008 100644
--- a/lms/static/js/spec/edxnotes/views/notes_visibility_factory_spec.js
+++ b/lms/static/js/spec/edxnotes/views/notes_visibility_factory_spec.js
@@ -1,9 +1,8 @@
define([
'jquery', 'underscore', 'annotator_1.2.9', 'common/js/spec_helpers/ajax_helpers',
- 'js/edxnotes/views/notes_visibility_factory', 'js/spec/edxnotes/helpers',
- 'js/spec/edxnotes/custom_matchers', 'jasmine-jquery'
+ 'js/edxnotes/views/notes_visibility_factory', 'js/spec/edxnotes/helpers'
], function(
- $, _, Annotator, AjaxHelpers, NotesVisibilityFactory, Helpers, customMatchers
+ $, _, Annotator, AjaxHelpers, NotesVisibilityFactory, Helpers
) {
'use strict';
describe('EdxNotes ToggleNotesFactory', function() {
@@ -17,7 +16,6 @@ define([
};
beforeEach(function() {
- customMatchers(this);
loadFixtures(
'js/fixtures/edxnotes/edxnotes_wrapper.html',
'js/fixtures/edxnotes/toggle_notes.html'
@@ -32,7 +30,7 @@ define([
this.button = $('.action-toggle-notes');
this.label = this.button.find('.utility-control-label');
this.toggleMessage = $('.action-toggle-message');
- spyOn(this.toggleNotes, 'toggleHandler').andCallThrough();
+ spyOn(this.toggleNotes, 'toggleHandler').and.callThrough();
});
afterEach(function () {
diff --git a/lms/static/js/spec/edxnotes/views/search_box_spec.js b/lms/static/js/spec/edxnotes/views/search_box_spec.js
index 3b1e780fcd..9c7bfceba5 100644
--- a/lms/static/js/spec/edxnotes/views/search_box_spec.js
+++ b/lms/static/js/spec/edxnotes/views/search_box_spec.js
@@ -1,7 +1,7 @@
define([
'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'js/edxnotes/views/search_box',
- 'js/edxnotes/collections/notes', 'js/spec/edxnotes/custom_matchers', 'js/spec/edxnotes/helpers', 'jasmine-jquery'
-], function($, _, AjaxHelpers, SearchBoxView, NotesCollection, customMatchers, Helpers) {
+ 'js/edxnotes/collections/notes', 'js/spec/edxnotes/helpers'
+], function($, _, AjaxHelpers, SearchBoxView, NotesCollection, Helpers) {
'use strict';
describe('EdxNotes SearchBoxView', function() {
var getSearchBox, submitForm, assertBoxIsEnabled, assertBoxIsDisabled, searchResponse;
@@ -47,7 +47,6 @@ define([
};
beforeEach(function () {
- customMatchers(this);
loadFixtures('js/fixtures/edxnotes/edxnotes.html');
spyOn(Logger, 'log');
this.searchBox = getSearchBox();
diff --git a/lms/static/js/spec/edxnotes/views/shim_spec.js b/lms/static/js/spec/edxnotes/views/shim_spec.js
index c568f6cb13..37795ce8cb 100644
--- a/lms/static/js/spec/edxnotes/views/shim_spec.js
+++ b/lms/static/js/spec/edxnotes/views/shim_spec.js
@@ -1,5 +1,5 @@
define([
- 'jquery', 'underscore', 'annotator_1.2.9', 'js/edxnotes/views/notes_factory', 'jasmine-jquery'
+ 'jquery', 'underscore', 'annotator_1.2.9', 'js/edxnotes/views/notes_factory'
], function($, _, Annotator, NotesFactory) {
'use strict';
describe('EdxNotes Shim', function() {
@@ -38,11 +38,11 @@ define([
];
_.each(annotators, function(annotator) {
highlights.push($('').appendTo(annotator.element));
- spyOn(annotator, 'onHighlightClick').andCallThrough();
- spyOn(annotator, 'onHighlightMouseover').andCallThrough();
- spyOn(annotator, 'startViewerHideTimer').andCallThrough();
+ spyOn(annotator, 'onHighlightClick').and.callThrough();
+ spyOn(annotator, 'onHighlightMouseover').and.callThrough();
+ spyOn(annotator, 'startViewerHideTimer').and.callThrough();
});
- spyOn($.fn, 'off').andCallThrough();
+ spyOn($.fn, 'off').and.callThrough();
});
afterEach(function () {
@@ -59,9 +59,9 @@ define([
});
it('clicking on highlights does not open the viewer when the editor is opened', function() {
- spyOn(annotators[1].editor, 'isShown').andReturn(false);
+ spyOn(annotators[1].editor, 'isShown').and.returnValue(false);
highlights[0].click();
- annotators[1].editor.isShown.andReturn(true);
+ annotators[1].editor.isShown.and.returnValue(true);
highlights[1].click();
expect($('#edx-notes-wrapper-123 .annotator-viewer')).not.toHaveClass('annotator-hide');
expect($('#edx-notes-wrapper-456 .annotator-viewer')).toHaveClass('annotator-hide');
@@ -76,7 +76,7 @@ define([
// in turn calls onHighlightMouseover.
// To test if onHighlightMouseover is called or not on
// mouseover, we'll have to reset onHighlightMouseover.
- annotators[0].onHighlightMouseover.reset();
+ annotators[0].onHighlightMouseover.calls.reset();
// Check that both instances of annotator are frozen
_.invoke(highlights, 'mouseover');
_.invoke(highlights, 'mouseout');
@@ -86,7 +86,7 @@ define([
it('clicking twice reverts to default behavior', function() {
highlights[0].click();
$(document).click();
- annotators[0].onHighlightMouseover.reset();
+ annotators[0].onHighlightMouseover.calls.reset();
// Check that both instances of annotator are unfrozen
_.invoke(highlights, 'mouseover');
@@ -116,7 +116,7 @@ define([
'and unbinds one document click.edxnotes:freeze event handlers', function() {
// Freeze all instances
highlights[0].click();
- annotators[0].onHighlightMouseover.reset();
+ annotators[0].onHighlightMouseover.calls.reset();
// Destroy second instance
annotators[1].destroy();
@@ -163,17 +163,17 @@ define([
element: element
};
- mockViewer.on = jasmine.createSpy().andReturn(mockViewer);
- mockViewer.hide = jasmine.createSpy().andReturn(mockViewer);
- mockViewer.destroy = jasmine.createSpy().andReturn(mockViewer);
- mockViewer.addField = jasmine.createSpy().andCallFake(function (options) {
+ mockViewer.on = jasmine.createSpy().and.returnValue(mockViewer);
+ mockViewer.hide = jasmine.createSpy().and.returnValue(mockViewer);
+ mockViewer.destroy = jasmine.createSpy().and.returnValue(mockViewer);
+ mockViewer.addField = jasmine.createSpy().and.callFake(function (options) {
mockViewer.fields.push(options);
return mockViewer;
});
- spyOn(element, 'bind').andReturn(element);
- spyOn(element, 'appendTo').andReturn(element);
- spyOn(Annotator, 'Viewer').andReturn(mockViewer);
+ spyOn(element, 'bind').and.returnValue(element);
+ spyOn(element, 'appendTo').and.returnValue(element);
+ spyOn(Annotator, 'Viewer').and.returnValue(mockViewer);
annotators[0]._setupViewer();
});
@@ -183,13 +183,13 @@ define([
});
it('should hide the annotator on creation', function () {
- expect(mockViewer.hide.callCount).toBe(1);
+ expect(mockViewer.hide.calls.count()).toBe(1);
});
it('should setup the default text field', function () {
- var args = mockViewer.addField.mostRecentCall.args[0];
+ var args = mockViewer.addField.calls.mostRecent().args[0];
- expect(mockViewer.addField.callCount).toBe(1);
+ expect(mockViewer.addField.calls.count()).toBe(1);
expect(_.isFunction(args.load)).toBeTruthy();
});
diff --git a/lms/static/js/spec/edxnotes/views/tab_item_spec.js b/lms/static/js/spec/edxnotes/views/tab_item_spec.js
index d455f2d6f9..4e7cc208f3 100644
--- a/lms/static/js/spec/edxnotes/views/tab_item_spec.js
+++ b/lms/static/js/spec/edxnotes/views/tab_item_spec.js
@@ -1,11 +1,10 @@
define([
'jquery', 'common/js/spec_helpers/template_helpers', 'js/edxnotes/collections/tabs',
- 'js/edxnotes/views/tabs_list', 'js/spec/edxnotes/custom_matchers', 'jasmine-jquery'
-], function($, TemplateHelpers, TabsCollection, TabsListView, customMatchers) {
+ 'js/edxnotes/views/tabs_list'
+], function($, TemplateHelpers, TabsCollection, TabsListView) {
'use strict';
describe('EdxNotes TabItemView', function() {
beforeEach(function () {
- customMatchers(this);
TemplateHelpers.installTemplate('templates/edxnotes/tab-item');
this.collection = new TabsCollection([
{identifier: 'first-item'},
diff --git a/lms/static/js/spec/edxnotes/views/tab_view_spec.js b/lms/static/js/spec/edxnotes/views/tab_view_spec.js
index 690d5f3339..6fb7400c27 100644
--- a/lms/static/js/spec/edxnotes/views/tab_view_spec.js
+++ b/lms/static/js/spec/edxnotes/views/tab_view_spec.js
@@ -1,9 +1,8 @@
define([
'jquery', 'backbone', 'common/js/spec_helpers/template_helpers', 'js/edxnotes/collections/tabs',
- 'js/edxnotes/views/tabs_list', 'js/edxnotes/views/tab_view',
- 'js/spec/edxnotes/custom_matchers', 'jasmine-jquery'
+ 'js/edxnotes/views/tabs_list', 'js/edxnotes/views/tab_view'
], function(
- $, Backbone, TemplateHelpers, TabsCollection, TabsListView, TabView, customMatchers
+ $, Backbone, TemplateHelpers, TabsCollection, TabsListView, TabView
) {
'use strict';
describe('EdxNotes TabView', function() {
@@ -41,7 +40,6 @@ define([
};
beforeEach(function () {
- customMatchers(this);
loadFixtures('js/fixtures/edxnotes/edxnotes.html');
TemplateHelpers.installTemplates([
'templates/edxnotes/note-item', 'templates/edxnotes/tab-item'
diff --git a/lms/static/js/spec/edxnotes/views/tabs/course_structure_spec.js b/lms/static/js/spec/edxnotes/views/tabs/course_structure_spec.js
index 39b01573bd..f372118456 100644
--- a/lms/static/js/spec/edxnotes/views/tabs/course_structure_spec.js
+++ b/lms/static/js/spec/edxnotes/views/tabs/course_structure_spec.js
@@ -1,11 +1,9 @@
define([
'jquery', 'underscore', 'common/js/spec_helpers/template_helpers', 'js/spec/edxnotes/helpers',
'js/edxnotes/collections/notes', 'js/edxnotes/collections/tabs',
- 'js/edxnotes/views/tabs/course_structure', 'js/spec/edxnotes/custom_matchers',
- 'jasmine-jquery'
+ 'js/edxnotes/views/tabs/course_structure'
], function(
- $, _, TemplateHelpers, Helpers, NotesCollection, TabsCollection, CourseStructureView,
- customMatchers
+ $, _, TemplateHelpers, Helpers, NotesCollection, TabsCollection, CourseStructureView
) {
'use strict';
describe('EdxNotes CourseStructureView', function() {
@@ -34,7 +32,6 @@ define([
};
beforeEach(function () {
- customMatchers(this);
loadFixtures('js/fixtures/edxnotes/edxnotes.html');
TemplateHelpers.installTemplates([
'templates/edxnotes/note-item', 'templates/edxnotes/tab-item'
diff --git a/lms/static/js/spec/edxnotes/views/tabs/recent_activity_spec.js b/lms/static/js/spec/edxnotes/views/tabs/recent_activity_spec.js
index fa18680809..de731caf34 100644
--- a/lms/static/js/spec/edxnotes/views/tabs/recent_activity_spec.js
+++ b/lms/static/js/spec/edxnotes/views/tabs/recent_activity_spec.js
@@ -1,9 +1,9 @@
define([
'jquery', 'common/js/spec_helpers/template_helpers', 'common/js/spec_helpers/ajax_helpers',
'js/edxnotes/collections/notes', 'js/edxnotes/collections/tabs', 'js/edxnotes/views/tabs/recent_activity',
- 'js/spec/edxnotes/custom_matchers', 'js/spec/edxnotes/helpers', 'jasmine-jquery'
+ 'js/spec/edxnotes/helpers'
], function(
- $, TemplateHelpers, AjaxHelpers, NotesCollection, TabsCollection, RecentActivityView, customMatchers, Helpers
+ $, TemplateHelpers, AjaxHelpers, NotesCollection, TabsCollection, RecentActivityView, Helpers
) {
'use strict';
describe('EdxNotes RecentActivityView', function() {
@@ -64,7 +64,6 @@ define([
recentActivityTabId = '#recent-panel';
beforeEach(function () {
- customMatchers(this);
loadFixtures('js/fixtures/edxnotes/edxnotes.html');
TemplateHelpers.installTemplates([
'templates/edxnotes/note-item', 'templates/edxnotes/tab-item'
diff --git a/lms/static/js/spec/edxnotes/views/tabs/search_results_spec.js b/lms/static/js/spec/edxnotes/views/tabs/search_results_spec.js
index 58286bf1e8..df24fda839 100644
--- a/lms/static/js/spec/edxnotes/views/tabs/search_results_spec.js
+++ b/lms/static/js/spec/edxnotes/views/tabs/search_results_spec.js
@@ -1,10 +1,9 @@
define([
'jquery', 'underscore', 'common/js/spec_helpers/template_helpers', 'common/js/spec_helpers/ajax_helpers',
'logger', 'js/edxnotes/collections/tabs', 'js/edxnotes/views/tabs/search_results',
- 'js/spec/edxnotes/custom_matchers', 'js/spec/edxnotes/helpers', 'jasmine-jquery'
+ 'js/spec/edxnotes/helpers'
], function(
- $, _, TemplateHelpers, AjaxHelpers, Logger, TabsCollection, SearchResultsView,
- customMatchers, Helpers
+ $, _, TemplateHelpers, AjaxHelpers, Logger, TabsCollection, SearchResultsView, Helpers
) {
'use strict';
describe('EdxNotes SearchResultsView', function() {
@@ -69,7 +68,6 @@ define([
searchResultsTabId = "#search-results-panel";
beforeEach(function () {
- customMatchers(this);
loadFixtures('js/fixtures/edxnotes/edxnotes.html');
TemplateHelpers.installTemplates([
'templates/edxnotes/note-item', 'templates/edxnotes/tab-item'
@@ -146,7 +144,7 @@ define([
it('can clear search results if tab is closed', function () {
var view = getView(this.tabsCollection),
requests = AjaxHelpers.requests(this);
- spyOn(view.searchBox, 'clearInput').andCallThrough();
+ spyOn(view.searchBox, 'clearInput').and.callThrough();
submitForm(view.searchBox, 'test_query');
Helpers.respondToRequest(requests, responseJson, true);
diff --git a/lms/static/js/spec/edxnotes/views/tabs/tags_spec.js b/lms/static/js/spec/edxnotes/views/tabs/tags_spec.js
index 811167f589..fdeeec1dde 100644
--- a/lms/static/js/spec/edxnotes/views/tabs/tags_spec.js
+++ b/lms/static/js/spec/edxnotes/views/tabs/tags_spec.js
@@ -1,11 +1,9 @@
define([
'jquery', 'underscore', 'common/js/spec_helpers/template_helpers', 'js/spec/edxnotes/helpers',
'js/edxnotes/collections/notes', 'js/edxnotes/collections/tabs',
- 'js/edxnotes/views/tabs/tags', 'js/spec/edxnotes/custom_matchers',
- 'jasmine-jquery'
+ 'js/edxnotes/views/tabs/tags'
], function(
- $, _, TemplateHelpers, Helpers, NotesCollection, TabsCollection, TagsView,
- customMatchers
+ $, _, TemplateHelpers, Helpers, NotesCollection, TabsCollection, TagsView
) {
'use strict';
describe('EdxNotes TagsView', function() {
@@ -38,7 +36,6 @@ define([
};
beforeEach(function () {
- customMatchers(this);
loadFixtures('js/fixtures/edxnotes/edxnotes.html');
TemplateHelpers.installTemplates([
'templates/edxnotes/note-item', 'templates/edxnotes/tab-item'
diff --git a/lms/static/js/spec/edxnotes/views/tabs_list_spec.js b/lms/static/js/spec/edxnotes/views/tabs_list_spec.js
index 35bddcd34d..5109405c79 100644
--- a/lms/static/js/spec/edxnotes/views/tabs_list_spec.js
+++ b/lms/static/js/spec/edxnotes/views/tabs_list_spec.js
@@ -1,11 +1,10 @@
define([
'jquery', 'common/js/spec_helpers/template_helpers', 'js/edxnotes/collections/tabs',
- 'js/edxnotes/views/tabs_list', 'js/spec/edxnotes/custom_matchers', 'jasmine-jquery'
-], function($, TemplateHelpers, TabsCollection, TabsListView, customMatchers) {
+ 'js/edxnotes/views/tabs_list'
+], function($, TemplateHelpers, TabsCollection, TabsListView) {
'use strict';
describe('EdxNotes TabsListView', function() {
beforeEach(function () {
- customMatchers(this);
TemplateHelpers.installTemplate('templates/edxnotes/tab-item');
this.collection = new TabsCollection([
{identifier: 'first-item'},
diff --git a/lms/static/js/spec/edxnotes/views/visibility_decorator_spec.js b/lms/static/js/spec/edxnotes/views/visibility_decorator_spec.js
index ddd9c651b1..3aa99b33dc 100644
--- a/lms/static/js/spec/edxnotes/views/visibility_decorator_spec.js
+++ b/lms/static/js/spec/edxnotes/views/visibility_decorator_spec.js
@@ -1,7 +1,7 @@
define([
'annotator_1.2.9', 'js/edxnotes/views/visibility_decorator',
- 'js/spec/edxnotes/helpers', 'js/spec/edxnotes/custom_matchers'
-], function(Annotator, VisibilityDecorator, Helpers, customMatchers) {
+ 'js/spec/edxnotes/helpers'
+], function(Annotator, VisibilityDecorator, Helpers) {
'use strict';
describe('EdxNotes VisibilityDecorator', function() {
var params = {
@@ -14,7 +14,6 @@ define([
};
beforeEach(function() {
- customMatchers(this);
loadFixtures('js/fixtures/edxnotes/edxnotes_wrapper.html');
this.wrapper = document.getElementById('edx-notes-wrapper-123');
});
diff --git a/lms/static/js/spec/financial-assistance/financial_assistance_form_view_spec.js b/lms/static/js/spec/financial-assistance/financial_assistance_form_view_spec.js
index 2aca04e9f6..cc1a68fcd3 100644
--- a/lms/static/js/spec/financial-assistance/financial_assistance_form_view_spec.js
+++ b/lms/static/js/spec/financial-assistance/financial_assistance_form_view_spec.js
@@ -108,7 +108,7 @@ define([
view.$('#financial-assistance-course').val(selectValue);
view.$('#financial-assistance-income').val(1312);
- view.$('textarea').html('w'.repeat(801));
+ view.$('textarea').html(Array(802).join("w"));
};
validSubmission = function() {
diff --git a/lms/static/js/spec/instructor_dashboard/certificates_bulk_exception_spec.js b/lms/static/js/spec/instructor_dashboard/certificates_bulk_exception_spec.js
index ce9d81658c..9763baee7a 100644
--- a/lms/static/js/spec/instructor_dashboard/certificates_bulk_exception_spec.js
+++ b/lms/static/js/spec/instructor_dashboard/certificates_bulk_exception_spec.js
@@ -31,7 +31,7 @@ define([
it('bind the ajax call and the result will be success', function() {
var submitCallback;
- spyOn($, "ajax").andCallFake(function(params) {
+ spyOn($, "ajax").and.callFake(function(params) {
params.success({
row_errors: {},
general_errors: [],
@@ -41,7 +41,7 @@ define([
always: function() {}
};
});
- submitCallback = jasmine.createSpy().andReturn();
+ submitCallback = jasmine.createSpy().and.returnValue();
this.view.$el.find(SELECTORS.bulk_white_list_exception_form).submit(submitCallback);
this.view.$el.find(SELECTORS.upload_csv_button).click();
expect($(SELECTORS.bulk_exception_results).text()).toContain('1 learner is successfully added to the ' +
@@ -50,7 +50,7 @@ define([
it('bind the ajax call and the result will be general error', function() {
var submitCallback;
- spyOn($, "ajax").andCallFake(function(params) {
+ spyOn($, "ajax").and.callFake(function(params) {
params.success({
row_errors: {},
general_errors: ["File is not attached."],
@@ -60,7 +60,7 @@ define([
always: function() {}
};
});
- submitCallback = jasmine.createSpy().andReturn();
+ submitCallback = jasmine.createSpy().and.returnValue();
this.view.$el.find(SELECTORS.bulk_white_list_exception_form).submit(submitCallback);
this.view.$el.find(SELECTORS.upload_csv_button).click();
expect($(SELECTORS.bulk_exception_results).text()).toContain('File is not attached.');
@@ -68,7 +68,7 @@ define([
it('bind the ajax call and the result will be singular form of row errors', function() {
var submitCallback;
- spyOn($, "ajax").andCallFake(function(params) {
+ spyOn($, "ajax").and.callFake(function(params) {
params.success({
general_errors: [],
row_errors: {
@@ -83,7 +83,7 @@ define([
always: function() {}
};
});
- submitCallback = jasmine.createSpy().andReturn();
+ submitCallback = jasmine.createSpy().and.returnValue();
this.view.$el.find(SELECTORS.bulk_white_list_exception_form).submit(submitCallback);
this.view.$el.find(SELECTORS.upload_csv_button).click();
expect($(SELECTORS.bulk_exception_results).text()).toContain('1 record is not in correct format');
@@ -95,7 +95,7 @@ define([
it('bind the ajax call and the result will be plural form of row errors', function() {
var submitCallback;
- spyOn($, "ajax").andCallFake(function(params) {
+ spyOn($, "ajax").and.callFake(function(params) {
params.success({
general_errors: [],
row_errors: {
@@ -110,7 +110,7 @@ define([
always: function() {}
};
});
- submitCallback = jasmine.createSpy().andReturn();
+ submitCallback = jasmine.createSpy().and.returnValue();
this.view.$el.find(SELECTORS.bulk_white_list_exception_form).submit(submitCallback);
this.view.$el.find(SELECTORS.upload_csv_button).click();
expect($(SELECTORS.bulk_exception_results).text()).toContain('2 records are not in correct format');
@@ -122,7 +122,7 @@ define([
it('toggle message details', function() {
var submitCallback;
- spyOn($, "ajax").andCallFake(function(params) {
+ spyOn($, "ajax").and.callFake(function(params) {
params.success({
row_errors: {},
general_errors: [],
@@ -132,7 +132,7 @@ define([
always: function() {}
};
});
- submitCallback = jasmine.createSpy().andReturn();
+ submitCallback = jasmine.createSpy().and.returnValue();
this.view.$el.find(SELECTORS.bulk_white_list_exception_form).submit(submitCallback);
this.view.$el.find(SELECTORS.upload_csv_button).click();
expect(this.view.$el.find("div.message > .successfully-added")).toBeHidden();
diff --git a/lms/static/js/spec/instructor_dashboard/certificates_spec.js b/lms/static/js/spec/instructor_dashboard/certificates_spec.js
index 6db15104dd..870ca8202b 100644
--- a/lms/static/js/spec/instructor_dashboard/certificates_spec.js
+++ b/lms/static/js/spec/instructor_dashboard/certificates_spec.js
@@ -65,21 +65,21 @@ define([
});
it("does not regenerate certificates if user cancels operation in confirm popup", function() {
- spyOn(window, 'confirm').andReturn(false);
+ spyOn(window, 'confirm').and.returnValue(false);
$regenerate_certificates_button.click();
expect(window.confirm).toHaveBeenCalled();
AjaxHelpers.expectNoRequests(requests);
});
it("sends regenerate certificates request if user accepts operation in confirm popup", function() {
- spyOn(window, 'confirm').andReturn(true);
+ spyOn(window, 'confirm').and.returnValue(true);
$regenerate_certificates_button.click();
expect(window.confirm).toHaveBeenCalled();
AjaxHelpers.expectRequest(requests, 'POST', expected.url);
});
it("sends regenerate certificates request with selected certificate statuses", function() {
- spyOn(window, 'confirm').andReturn(true);
+ spyOn(window, 'confirm').and.returnValue(true);
select_options(expected.selected_statuses);
@@ -88,7 +88,7 @@ define([
});
it("displays error message in case of server side error", function() {
- spyOn(window, 'confirm').andReturn(true);
+ spyOn(window, 'confirm').and.returnValue(true);
select_options(expected.selected_statuses);
$regenerate_certificates_button.click();
@@ -97,7 +97,7 @@ define([
});
it("displays error message returned by the server in case of unsuccessful request", function() {
- spyOn(window, 'confirm').andReturn(true);
+ spyOn(window, 'confirm').and.returnValue(true);
select_options(expected.selected_statuses);
$regenerate_certificates_button.click();
@@ -106,7 +106,7 @@ define([
});
it("displays success message returned by the server in case of successful request", function() {
- spyOn(window, 'confirm').andReturn(true);
+ spyOn(window, 'confirm').and.returnValue(true);
select_options(expected.selected_statuses);
$regenerate_certificates_button.click();
diff --git a/lms/static/js/spec/instructor_dashboard/ecommerce_spec.js b/lms/static/js/spec/instructor_dashboard/ecommerce_spec.js
index 273fbd6f53..c2c8d7cb8c 100644
--- a/lms/static/js/spec/instructor_dashboard/ecommerce_spec.js
+++ b/lms/static/js/spec/instructor_dashboard/ecommerce_spec.js
@@ -24,7 +24,7 @@ define(['backbone', 'jquery', 'js/instructor_dashboard/ecommerce'],
var target = expiryCouponView.$el.find('input[type="checkbox"]');
target.attr("checked","checked");
target.click();
- expect(expiryCouponView.$el.find('#coupon_expiration_date')).toHaveAttr('style','display: inline;');
+ expect(expiryCouponView.$el.find('#coupon_expiration_date').is(':visible')).toBe(true);
});
it("hides the input field when the checkbox is unchecked", function () {
diff --git a/lms/static/js/spec/instructor_dashboard/student_admin_spec.js b/lms/static/js/spec/instructor_dashboard/student_admin_spec.js
index fe432883c5..662930be63 100644
--- a/lms/static/js/spec/instructor_dashboard/student_admin_spec.js
+++ b/lms/static/js/spec/instructor_dashboard/student_admin_spec.js
@@ -17,7 +17,7 @@ define(['jquery', 'coffee/src/instructor_dashboard/student_admin', 'common/js/sp
dashboard_api_url = '/courses/PU/FSc/2014_T4/instructor/api';
unique_student_identifier = "test@example.com";
alert_msg = '';
- spyOn(window, 'alert').andCallFake(function(message) {
+ spyOn(window, 'alert').and.callFake(function(message) {
alert_msg = message;
});
diff --git a/lms/static/js/spec/main.js b/lms/static/js/spec/main.js
index 3e7fa0e844..f77aeca6bd 100644
--- a/lms/static/js/spec/main.js
+++ b/lms/static/js/spec/main.js
@@ -47,7 +47,8 @@
'squire': 'xmodule_js/common_static/js/vendor/Squire',
'jasmine-imagediff': 'xmodule_js/common_static/js/vendor/jasmine-imagediff',
'jasmine-stealth': 'xmodule_js/common_static/js/vendor/jasmine-stealth',
- 'jasmine-waituntil': 'xmodule_js/common_static/js/vendor/jasmine-waituntil',
+ 'jasmine-waituntil': 'xmodule_js/common_static/js/libs/jasmine-waituntil',
+ 'jasmine-extensions': 'xmodule_js/common_static/js/libs/jasmine-extensions',
'draggabilly': 'xmodule_js/common_static/js/vendor/draggabilly.pkgd',
'domReady': 'xmodule_js/common_static/js/vendor/domReady',
'mathjax': '//cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?config=TeX-MML-AM_SVG&delayStartupUntil=configured', // jshint ignore:line
@@ -104,8 +105,8 @@
// Common edx utils
'common/js/utils/edx.utils.validate': 'xmodule_js/common_static/common/js/utils/edx.utils.validate',
- 'slick.grid': 'xmodule_js/common_static/js/vendor/slick.grid',
- 'slick.core': 'xmodule_js/common_static/js/vendor/slick.core'
+ 'slick.core': 'xmodule_js/common_static/js/vendor/slick.core',
+ 'slick.grid': 'xmodule_js/common_static/js/vendor/slick.grid'
},
shim: {
'gettext': {
@@ -265,6 +266,9 @@
'jasmine-waituntil': {
deps: ['jquery']
},
+ 'jasmine-extensions': {
+ deps: ['jquery']
+ },
'xblock/core': {
exports: 'XBlock',
deps: ['jquery', 'jquery.immediateDescendents']
@@ -362,11 +366,18 @@
deps: [ 'jquery', 'underscore', 'underscore.string', 'backbone', 'gettext' ],
init: function() {
// Set global variables that the payment code is expecting to be defined
- window._ = require('underscore');
- window._.str = require('underscore.string');
- window.edx = edx || {};
- window.edx.HtmlUtils = require('edx-ui-toolkit/js/utils/html-utils');
- window.edx.StringUtils = require('edx-ui-toolkit/js/utils/string-utils');
+ require([
+ 'underscore',
+ 'underscore.string',
+ 'edx-ui-toolkit/js/utils/html-utils',
+ 'edx-ui-toolkit/js/utils/string-utils'
+ ], function (_, str, HtmlUtils, StringUtils) {
+ window._ = _;
+ window._.str = str;
+ window.edx = edx || {};
+ window.edx.HtmlUtils = HtmlUtils;
+ window.edx.StringUtils = StringUtils;
+ });
}
},
'js/verify_student/views/intro_step_view': {
@@ -491,8 +502,10 @@
exports: 'DiscussionUtil',
init: function() {
// Set global variables that the discussion code is expecting to be defined
- window.Backbone = require('backbone');
- window.URI = require('URI');
+ require(['backbone', 'URI'], function (Backbone, URI) {
+ window.Backbone = Backbone;
+ window.URI = URI;
+ });
}
},
'xmodule_js/common_static/coffee/src/discussion/content': {
@@ -546,13 +559,15 @@
},
'xmodule_js/common_static/coffee/src/discussion/views/discussion_thread_show_view': {
deps: [
- 'xmodule_js/common_static/coffee/src/discussion/utils'
+ 'xmodule_js/common_static/coffee/src/discussion/utils',
+ 'xmodule_js/common_static/coffee/src/discussion/views/discussion_content_view'
],
exports: 'DiscussionThreadShowView'
},
'xmodule_js/common_static/coffee/src/discussion/views/discussion_thread_view': {
deps: [
- 'xmodule_js/common_static/coffee/src/discussion/utils'
+ 'xmodule_js/common_static/coffee/src/discussion/utils',
+ 'xmodule_js/common_static/coffee/src/discussion/views/discussion_content_view'
],
exports: 'DiscussionThreadView'
},
diff --git a/lms/static/js/spec/navigation_spec.js b/lms/static/js/spec/navigation_spec.js
index d0c51cd049..12e2964c59 100644
--- a/lms/static/js/spec/navigation_spec.js
+++ b/lms/static/js/spec/navigation_spec.js
@@ -15,7 +15,7 @@ define(['jquery', 'js/utils/navigation'], function($) {
chapterMenu = accordion.children('.chapter-content-container').children('.chapter-menu');
this.KEY = $.ui.keyCode;
- spyOn($.fn, 'focus').andCallThrough();
+ spyOn($.fn, 'focus').and.callThrough();
edx.util.navigation.init();
});
diff --git a/lms/static/js/spec/search/search_spec.js b/lms/static/js/spec/search/search_spec.js
index dce93d0ea3..7e18043dc0 100644
--- a/lms/static/js/spec/search/search_spec.js
+++ b/lms/static/js/spec/search/search_spec.js
@@ -77,14 +77,14 @@ define([
var collection = new SearchCollection([]);
spyOn($, 'ajax');
collection.performSearch('search string');
- expect($.ajax.mostRecentCall.args[0].url).toEqual('/search/');
+ expect($.ajax.calls.mostRecent().args[0].url).toEqual('/search/');
});
it('sends a request with course ID', function () {
var collection = new SearchCollection([], { courseId: 'edx101' });
spyOn($, 'ajax');
collection.performSearch('search string');
- expect($.ajax.mostRecentCall.args[0].url).toEqual('/search/edx101');
+ expect($.ajax.calls.mostRecent().args[0].url).toEqual('/search/edx101');
});
it('sends a request and parses the json result', function () {
@@ -139,10 +139,10 @@ define([
AjaxHelpers.respondWithJson(requests, response);
spyOn($, 'ajax');
this.collection.loadNextPage();
- expect($.ajax.mostRecentCall.args[0].url).toEqual(this.collection.url);
- expect($.ajax.mostRecentCall.args[0].data.search_string).toEqual(searchString);
- expect($.ajax.mostRecentCall.args[0].data.page_size).toEqual(this.collection.pageSize);
- expect($.ajax.mostRecentCall.args[0].data.page_index).toEqual(2);
+ expect($.ajax.calls.mostRecent().args[0].url).toEqual(this.collection.url);
+ expect($.ajax.calls.mostRecent().args[0].data.search_string).toEqual(searchString);
+ expect($.ajax.calls.mostRecent().args[0].data.page_size).toEqual(this.collection.pageSize);
+ expect($.ajax.calls.mostRecent().args[0].data.page_index).toEqual(2);
});
it('has next page', function () {
@@ -164,18 +164,18 @@ define([
this.collection.performSearch('new search');
AjaxHelpers.skipResetRequest(requests);
AjaxHelpers.respondWithJson(requests, response);
- expect(this.onSearch.calls.length).toEqual(1);
+ expect(this.onSearch.calls.count()).toEqual(1);
this.collection.performSearch('old search');
this.collection.cancelSearch();
AjaxHelpers.skipResetRequest(requests);
- expect(this.onSearch.calls.length).toEqual(1);
+ expect(this.onSearch.calls.count()).toEqual(1);
this.collection.loadNextPage();
this.collection.loadNextPage();
AjaxHelpers.skipResetRequest(requests);
AjaxHelpers.respondWithJson(requests, response);
- expect(this.onNext.calls.length).toEqual(1);
+ expect(this.onNext.calls.count()).toEqual(1);
});
describe('reset state', function () {
@@ -261,7 +261,7 @@ define([
function rendersItem() {
expect(this.item.$el).toHaveAttr('role', 'region');
expect(this.item.$el).toHaveAttr('aria-label', 'search result');
- expect(this.item.$el).toContain('a[href="' + this.model.get('url') + '"]');
+ expect(this.item.$el).toContainElement('a[href="' + this.model.get('url') + '"]');
expect(this.item.$el.find('.result-type')).toContainHtml(this.model.get('content_type'));
expect(this.item.$el.find('.result-excerpt')).toContainHtml(this.model.get('excerpt'));
expect(this.item.$el.find('.result-location')).toContainHtml('section ▸ subsection ▸ unit');
@@ -270,7 +270,7 @@ define([
function rendersSequentialItem() {
expect(this.seqItem.$el).toHaveAttr('role', 'region');
expect(this.seqItem.$el).toHaveAttr('aria-label', 'search result');
- expect(this.seqItem.$el).toContain('a[href="' + this.seqModel.get('url') + '"]');
+ expect(this.seqItem.$el).toContainElement('a[href="' + this.seqModel.get('url') + '"]');
expect(this.seqItem.$el.find('.result-type')).toBeEmpty();
expect(this.seqItem.$el.find('.result-excerpt')).toBeEmpty();
expect(this.seqItem.$el.find('.result-location')).toContainHtml('section ▸ subsection');
@@ -280,8 +280,8 @@ define([
this.model.collection = new SearchCollection([this.model], { course_id: 'edx101' });
this.item.render();
// Mock the redirect call
- spyOn(this.item, 'redirect').andCallFake( function() {} );
- spyOn(Logger, 'log').andReturn($.Deferred().resolve());
+ spyOn(this.item, 'redirect').and.callFake( function() {} );
+ spyOn(Logger, 'log').and.returnValue($.Deferred().resolve());
this.item.$el.find('a').trigger('click');
expect(this.item.redirect).toHaveBeenCalled();
this.item.$el.trigger('click');
@@ -498,7 +498,6 @@ define([
'templates/search/dashboard_search_item',
'templates/search/course_search_results',
'templates/search/dashboard_search_results',
- 'templates/search/search_list',
'templates/search/search_loading',
'templates/search/search_error'
]);
@@ -601,9 +600,9 @@ define([
function updatesNavigationHistory () {
$('.search-field').val('edx');
$('.search-button').trigger('click');
- expect(Backbone.history.navigate.calls[0].args).toContain('search/edx');
+ expect(Backbone.history.navigate.calls.mostRecent().args[0]).toContain('search/edx');
$('.cancel-button').trigger('click');
- expect(Backbone.history.navigate.calls[1].args).toContain('');
+ expect(Backbone.history.navigate.calls.argsFor(1)[0]).toBe('');
}
function cancelsSearchRequest () {
diff --git a/lms/static/js/spec/shoppingcart/shoppingcart_spec.js b/lms/static/js/spec/shoppingcart/shoppingcart_spec.js
index 1f0da04fc8..0f86f7c9f8 100644
--- a/lms/static/js/spec/shoppingcart/shoppingcart_spec.js
+++ b/lms/static/js/spec/shoppingcart/shoppingcart_spec.js
@@ -13,7 +13,7 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/shoppingcart/shoppingcart'],
el: $('.confirm-enrollment.cart-view form')
});
- spyOn(view, 'responseFromServer').andCallFake(function() {});
+ spyOn(view, 'responseFromServer').and.callFake(function() {});
// Spy on AJAX requests
requests = AjaxHelpers.requests(this);
@@ -36,7 +36,7 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/shoppingcart/shoppingcart'],
});
expect(view.responseFromServer).toHaveBeenCalled();
- var data = view.responseFromServer.mostRecentCall.args[0]
+ var data = view.responseFromServer.calls.mostRecent().args[0];
expect(data.is_course_enrollment_closed).toBe(true);
});
@@ -50,7 +50,7 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/shoppingcart/shoppingcart'],
});
expect(view.responseFromServer).toHaveBeenCalled();
- var data = view.responseFromServer.mostRecentCall.args[0]
+ var data = view.responseFromServer.calls.mostRecent().args[0];
expect(data.is_course_enrollment_closed).toBe(false);
});
diff --git a/lms/static/js/spec/staff_debug_actions_spec.js b/lms/static/js/spec/staff_debug_actions_spec.js
index af92c098d6..3486fd7267 100644
--- a/lms/static/js/spec/staff_debug_actions_spec.js
+++ b/lms/static/js/spec/staff_debug_actions_spec.js
@@ -5,6 +5,8 @@ define([
'common/js/spec_helpers/ajax_helpers'
],
function (Backbone, $, tmp, AjaxHelpers) {
+ 'use strict';
+ var StaffDebug = window.StaffDebug;
describe('StaffDebugActions', function () {
var location = 'i4x://edX/Open_DemoX/edx_demo_course/problem/test_loc';
@@ -20,8 +22,10 @@ define([
describe('get_url ', function () {
it('defines url to courseware ajax entry point', function () {
- spyOn(StaffDebug, "get_current_url").andReturn("/courses/edX/Open_DemoX/edx_demo_course/courseware/stuff");
- expect(StaffDebug.get_url('rescore_problem')).toBe('/courses/edX/Open_DemoX/edx_demo_course/instructor/api/rescore_problem');
+ spyOn(StaffDebug, "get_current_url")
+ .and.returnValue("/courses/edX/Open_DemoX/edx_demo_course/courseware/stuff");
+ expect(StaffDebug.get_url('rescore_problem'))
+ .toBe('/courses/edX/Open_DemoX/edx_demo_course/instructor/api/rescore_problem');
});
});
@@ -87,13 +91,13 @@ define([
spyOn($, 'ajax');
StaffDebug.reset(locationName, location);
- expect($.ajax.mostRecentCall.args[0]['type']).toEqual('GET');
- expect($.ajax.mostRecentCall.args[0]['data']).toEqual({
+ expect($.ajax.calls.mostRecent().args[0].type).toEqual('GET');
+ expect($.ajax.calls.mostRecent().args[0].data).toEqual({
'problem_to_reset': location,
'unique_student_identifier': 'userman',
'delete_module': false
});
- expect($.ajax.mostRecentCall.args[0]['url']).toEqual(
+ expect($.ajax.calls.mostRecent().args[0].url).toEqual(
'/instructor/api/reset_student_attempts'
);
$('#' + fixture_id).remove();
@@ -106,13 +110,13 @@ define([
spyOn($, 'ajax');
StaffDebug.sdelete(locationName, location);
- expect($.ajax.mostRecentCall.args[0]['type']).toEqual('GET');
- expect($.ajax.mostRecentCall.args[0]['data']).toEqual({
+ expect($.ajax.calls.mostRecent().args[0].type).toEqual('GET');
+ expect($.ajax.calls.mostRecent().args[0].data).toEqual({
'problem_to_reset': location,
'unique_student_identifier': 'userman',
'delete_module': true
});
- expect($.ajax.mostRecentCall.args[0]['url']).toEqual(
+ expect($.ajax.calls.mostRecent().args[0].url).toEqual(
'/instructor/api/reset_student_attempts'
);
@@ -126,13 +130,13 @@ define([
spyOn($, 'ajax');
StaffDebug.rescore(locationName, location);
- expect($.ajax.mostRecentCall.args[0]['type']).toEqual('GET');
- expect($.ajax.mostRecentCall.args[0]['data']).toEqual({
+ expect($.ajax.calls.mostRecent().args[0].type).toEqual('GET');
+ expect($.ajax.calls.mostRecent().args[0].data).toEqual({
'problem_to_reset': location,
'unique_student_identifier': 'userman',
'delete_module': false
});
- expect($.ajax.mostRecentCall.args[0]['url']).toEqual(
+ expect($.ajax.calls.mostRecent().args[0].url).toEqual(
'/instructor/api/rescore_problem'
);
$('#' + fixture_id).remove();
diff --git a/lms/static/js/spec/student_account/access_spec.js b/lms/static/js/spec/student_account/access_spec.js
index 88a73c1506..1f6c334984 100644
--- a/lms/static/js/spec/student_account/access_spec.js
+++ b/lms/static/js/spec/student_account/access_spec.js
@@ -78,11 +78,11 @@
view = new AccessView(_.extend(options, {el: $logistrationElement}));
// Mock the redirect call
- spyOn( view, 'redirect' ).andCallFake( function() {} );
+ spyOn( view, 'redirect' ).and.callFake( function() {} );
// Mock the enrollment and shopping cart interfaces
- spyOn( EnrollmentInterface, 'enroll' ).andCallFake( function() {} );
- spyOn( ShoppingCartInterface, 'addCourseToCart' ).andCallFake( function() {} );
+ spyOn( EnrollmentInterface, 'enroll' ).and.callFake( function() {} );
+ spyOn( ShoppingCartInterface, 'addCourseToCart' ).and.callFake( function() {} );
};
var assertForms = function(visibleType, hiddenType) {
@@ -101,6 +101,7 @@
};
beforeEach(function() {
+ spyOn(window.history, 'pushState');
setFixtures('');
TemplateHelpers.installTemplate('templates/student_account/access');
TemplateHelpers.installTemplate('templates/student_account/login');
@@ -139,9 +140,6 @@
it('toggles between the login and registration forms', function() {
ajaxSpyAndInitialize(this, 'login');
- // Prevent URL from updating
- spyOn(history, 'pushState').andCallFake( function() {} );
-
// Simulate selection of the registration form
selectForm('register');
assertForms('#register-form', '#login-form');
diff --git a/lms/static/js/spec/student_account/account_settings_fields_spec.js b/lms/static/js/spec/student_account/account_settings_fields_spec.js
index 9d5b95616b..626c5b2f83 100644
--- a/lms/static/js/spec/student_account/account_settings_fields_spec.js
+++ b/lms/static/js/spec/student_account/account_settings_fields_spec.js
@@ -16,7 +16,11 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
beforeEach(function () {
timerCallback = jasmine.createSpy('timerCallback');
- jasmine.Clock.useMock();
+ jasmine.clock().install();
+ });
+
+ afterEach(function() {
+ jasmine.clock().uninstall();
});
it("sends request to reset password on clicking link in PasswordFieldView", function() {
diff --git a/lms/static/js/spec/student_account/account_spec.js b/lms/static/js/spec/student_account/account_spec.js
index 3262192baf..bbca8f8ee2 100644
--- a/lms/static/js/spec/student_account/account_spec.js
+++ b/lms/static/js/spec/student_account/account_spec.js
@@ -104,7 +104,7 @@ define(['js/student_account/account'],
var assertAjax = function(url, method, data) {
expect($.ajax).toHaveBeenCalled();
- var ajaxArgs = $.ajax.mostRecentCall.args[0];
+ var ajaxArgs = $.ajax.calls.mostRecent().args[0];
expect(ajaxArgs.url).toEqual(url);
expect(ajaxArgs.type).toEqual(method);
expect(ajaxArgs.data).toEqual(data);
@@ -127,7 +127,7 @@ define(['js/student_account/account'],
view = new edx.student.account.AccountView().render();
// Stub Ajax calls to return success/failure
- spyOn($, "ajax").andCallFake(function() {
+ spyOn($, "ajax").and.callFake(function() {
return $.Deferred(function(defer) {
if (ajaxSuccess) {
defer.resolve();
diff --git a/lms/static/js/spec/student_account/enrollment_spec.js b/lms/static/js/spec/student_account/enrollment_spec.js
index 27cfdc9106..ac36790367 100644
--- a/lms/static/js/spec/student_account/enrollment_spec.js
+++ b/lms/static/js/spec/student_account/enrollment_spec.js
@@ -11,7 +11,7 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/enrollment'],
beforeEach(function() {
// Mock the redirect call
- spyOn(EnrollmentInterface, 'redirect').andCallFake(function() {});
+ spyOn(EnrollmentInterface, 'redirect').and.callFake(function() {});
});
it('enrolls a user in a course', function() {
diff --git a/lms/static/js/spec/student_account/finish_auth_spec.js b/lms/static/js/spec/student_account/finish_auth_spec.js
index 2086526631..53565ef157 100644
--- a/lms/static/js/spec/student_account/finish_auth_spec.js
+++ b/lms/static/js/spec/student_account/finish_auth_spec.js
@@ -27,13 +27,13 @@
view = new FinishAuthView({});
// Mock the redirect call
- spyOn( view, 'redirect' ).andCallFake( function() {} );
+ spyOn( view, 'redirect' ).and.callFake( function() {} );
// Mock the enrollment and shopping cart interfaces
- spyOn( EnrollmentInterface, 'enroll' ).andCallFake( function() {} );
- spyOn( ShoppingCartInterface, 'addCourseToCart' ).andCallFake( function() {} );
+ spyOn( EnrollmentInterface, 'enroll' ).and.callFake( function() {} );
+ spyOn( ShoppingCartInterface, 'addCourseToCart' ).and.callFake( function() {} );
spyOn( EmailOptInInterface, 'setPreference' )
- .andCallFake( function() { return {'always': function(r) { r(); }}; } );
+ .and.callFake( function() { return {'always': function(r) { r(); }}; } );
view.render();
};
@@ -45,7 +45,7 @@
* should be prefixed with '?'
*/
var setFakeQueryParams = function( params ) {
- spyOn( $, 'url' ).andCallFake(function( requestedParam ) {
+ spyOn( $, 'url' ).and.callFake(function( requestedParam ) {
if ( params.hasOwnProperty(requestedParam) ) {
return params[requestedParam];
}
diff --git a/lms/static/js/spec/student_account/hinted_login_spec.js b/lms/static/js/spec/student_account/hinted_login_spec.js
index 2a751b32d2..f21f1a8129 100644
--- a/lms/static/js/spec/student_account/hinted_login_spec.js
+++ b/lms/static/js/spec/student_account/hinted_login_spec.js
@@ -51,7 +51,7 @@
});
// Mock the redirect call
- spyOn( view, 'redirect' ).andCallFake( function() {} );
+ spyOn( view, 'redirect' ).and.callFake( function() {} );
view.render();
};
diff --git a/lms/static/js/spec/student_account/login_spec.js b/lms/static/js/spec/student_account/login_spec.js
index a94ada61a0..9bd5d9ba33 100644
--- a/lms/static/js/spec/student_account/login_spec.js
+++ b/lms/static/js/spec/student_account/login_spec.js
@@ -127,7 +127,7 @@
// spying on `view.validate` twice
if ( !_.isUndefined(validationSuccess) ) {
// Force validation to return as expected
- spyOn(view, 'validate').andReturn({
+ spyOn(view, 'validate').and.returnValue({
isValid: validationSuccess,
message: 'Submission was validated.'
});
@@ -173,7 +173,7 @@
// Simulate that the user is attempting to enroll in a course
// by setting the course_id query string param.
- spyOn($, 'url').andCallFake(function( param ) {
+ spyOn($, 'url').and.callFake(function( param ) {
if (param === '?course_id') {
return encodeURIComponent( COURSE_ID );
}
diff --git a/lms/static/js/spec/student_account/password_reset_spec.js b/lms/static/js/spec/student_account/password_reset_spec.js
index b3ebbc4e69..35aa6fb228 100644
--- a/lms/static/js/spec/student_account/password_reset_spec.js
+++ b/lms/static/js/spec/student_account/password_reset_spec.js
@@ -58,7 +58,7 @@
// spying on `view.validate` twice
if ( !_.isUndefined(validationSuccess) ) {
// Force validation to return as expected
- spyOn(view, 'validate').andReturn({
+ spyOn(view, 'validate').and.returnValue({
isValid: validationSuccess,
message: 'Submission was validated.'
});
diff --git a/lms/static/js/spec/student_account/register_spec.js b/lms/static/js/spec/student_account/register_spec.js
index f827e13e9d..5ba2e68bfa 100644
--- a/lms/static/js/spec/student_account/register_spec.js
+++ b/lms/static/js/spec/student_account/register_spec.js
@@ -220,7 +220,7 @@
// spying on `view.validate` twice
if ( !_.isUndefined(validationSuccess) ) {
// Force validation to return as expected
- spyOn(view, 'validate').andReturn({
+ spyOn(view, 'validate').and.returnValue({
isValid: validationSuccess,
message: 'Submission was validated.'
});
@@ -265,7 +265,7 @@
// Simulate that the user is attempting to enroll in a course
// by setting the course_id query string param.
- spyOn($, 'url').andCallFake(function( param ) {
+ spyOn($, 'url').and.callFake(function( param ) {
if (param === '?course_id') {
return encodeURIComponent( COURSE_ID );
}
diff --git a/lms/static/js/spec/student_account/shoppingcart_spec.js b/lms/static/js/spec/student_account/shoppingcart_spec.js
index 9048951dd2..8102781352 100644
--- a/lms/static/js/spec/student_account/shoppingcart_spec.js
+++ b/lms/static/js/spec/student_account/shoppingcart_spec.js
@@ -10,7 +10,7 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/shoppingcart'
beforeEach(function() {
// Mock the redirect call
- spyOn(ShoppingCartInterface, 'redirect').andCallFake(function() {});
+ spyOn(ShoppingCartInterface, 'redirect').and.callFake(function() {});
});
it('adds a course to the cart', function() {
diff --git a/lms/static/js/spec/verify_student/image_input_spec.js b/lms/static/js/spec/verify_student/image_input_spec.js
index 233159a859..81af419611 100644
--- a/lms/static/js/spec/verify_student/image_input_spec.js
+++ b/lms/static/js/spec/verify_student/image_input_spec.js
@@ -22,51 +22,41 @@ define([
}).render();
};
- var uploadImage = function( view, fileType, callback ) {
- var imageCapturedEvent = false,
- errorEvent = false;
+ var uploadImage = function( view, fileType ) {
+ var deferred = $.Deferred();
// Since image upload is an asynchronous process,
// we need to wait for the upload to complete
// before checking the outcome.
- runs(function() {
- var fakeFile,
- fakeEvent = { target: { files: [] } };
+ var fakeFile,
+ fakeEvent = { target: { files: [] } };
- // If no file type is specified, don't add any files.
- // This simulates what happens when the user clicks
- // "cancel" after clicking the input.
- if ( fileType !== null) {
- fakeFile = new Blob(
- [ IMAGE_DATA ],
- { type: 'image/' + fileType }
- );
- fakeEvent.target.files = [ fakeFile ];
- }
+ // If no file type is specified, don't add any files.
+ // This simulates what happens when the user clicks
+ // "cancel" after clicking the input.
+ if ( fileType !== null) {
+ fakeFile = new Blob(
+ [ IMAGE_DATA ],
+ { type: 'image/' + fileType }
+ );
+ fakeEvent.target.files = [ fakeFile ];
+ }
- // Wait for either a successful upload or an error
- view.on( 'imageCaptured', function() {
- imageCapturedEvent = true;
- });
- view.on( 'error', function() {
- errorEvent = true;
- });
-
- // Trigger the file input change
- // It's impossible to trigger this directly due
- // to browser security restrictions, so we call
- // the handler instead.
- view.handleInputChange( fakeEvent );
+ // Wait for either a successful upload or an error
+ view.on( 'imageCaptured', function() {
+ deferred.resolve();
+ });
+ view.on( 'error', function() {
+ deferred.resolve();
});
- // Check that the image upload has completed,
- // either successfully or with an error.
- waitsFor(function() {
- return ( imageCapturedEvent || errorEvent );
- });
+ // Trigger the file input change
+ // It's impossible to trigger this directly due
+ // to browser security restrictions, so we call
+ // the handler instead.
+ view.handleInputChange( fakeEvent );
- // Execute the callback to check expectations.
- runs( callback );
+ return deferred.promise();
};
var expectPreview = function( view, fileType ) {
@@ -112,45 +102,45 @@ define([
expectSubmitEnabled( false );
});
- it( 'uploads a png image', function() {
+ it( 'uploads a png image', function(done) {
var view = createView();
- uploadImage( view, 'png', function() {
+ uploadImage( view, 'png').then(function() {
expectPreview( view, 'png' );
expectSubmitEnabled( true );
expectImageData( view, 'png' );
- });
+ }).always(done);
});
- it( 'uploads a jpeg image', function() {
+ it( 'uploads a jpeg image', function(done) {
var view = createView();
- uploadImage( view, 'jpeg', function() {
+ uploadImage( view, 'jpeg').then(function() {
expectPreview( view, 'jpeg' );
expectSubmitEnabled( true );
expectImageData( view, 'jpeg' );
- } );
+ }).always(done);
});
- it( 'hides the preview when the user cancels the upload', function() {
+ it( 'hides the preview when the user cancels the upload', function(done) {
var view = createView();
- uploadImage( view, null, function() {
+ uploadImage( view, null).then(function() {
expectPreview( view, null );
expectSubmitEnabled( false );
expectImageData( view, null );
- } );
+ }).always(done);
});
- it( 'shows an error if the file type is not supported', function() {
+ it( 'shows an error if the file type is not supported', function(done) {
var view = createView();
- uploadImage( view, 'txt', function() {
+ uploadImage( view, 'txt').then(function() {
expectPreview( view, null );
expectError( view );
expectSubmitEnabled( false );
expectImageData( view, null );
- } );
+ }).always(done);
});
});
});
diff --git a/lms/static/js/spec/verify_student/make_payment_step_view_ab_testing_spec.js b/lms/static/js/spec/verify_student/make_payment_step_view_ab_testing_spec.js
index 27fa12573f..dbb5cf6e0e 100644
--- a/lms/static/js/spec/verify_student/make_payment_step_view_ab_testing_spec.js
+++ b/lms/static/js/spec/verify_student/make_payment_step_view_ab_testing_spec.js
@@ -37,7 +37,7 @@ define([
}).render();
// Stub the payment form submission
- spyOn( view, 'submitForm' ).andCallFake( function() {} );
+ spyOn( view, 'submitForm' ).and.callFake( function() {} );
return view;
};
@@ -97,7 +97,7 @@ define([
var form;
expect(view.submitForm).toHaveBeenCalled();
- form = view.submitForm.mostRecentCall.args[0];
+ form = view.submitForm.calls.mostRecent().args[0];
expect(form.serialize()).toEqual($.param(params));
expect(form.attr('method')).toEqual('POST');
diff --git a/lms/static/js/spec/verify_student/make_payment_step_view_spec.js b/lms/static/js/spec/verify_student/make_payment_step_view_spec.js
index cda80071fe..31389ed5f3 100644
--- a/lms/static/js/spec/verify_student/make_payment_step_view_spec.js
+++ b/lms/static/js/spec/verify_student/make_payment_step_view_spec.js
@@ -34,7 +34,7 @@ define([
}).render();
// Stub the payment form submission
- spyOn( view, 'submitForm' ).andCallFake( function() {} );
+ spyOn( view, 'submitForm' ).and.callFake( function() {} );
return view;
};
@@ -91,7 +91,7 @@ define([
var form;
expect(view.submitForm).toHaveBeenCalled();
- form = view.submitForm.mostRecentCall.args[0];
+ form = view.submitForm.calls.mostRecent().args[0];
expect(form.serialize()).toEqual($.param(params));
expect(form.attr('method')).toEqual("POST");
diff --git a/lms/static/js/spec/verify_student/pay_and_verify_view_spec.js b/lms/static/js/spec/verify_student/pay_and_verify_view_spec.js
index 8fb53b910f..53f4b1fd8b 100644
--- a/lms/static/js/spec/verify_student/pay_and_verify_view_spec.js
+++ b/lms/static/js/spec/verify_student/pay_and_verify_view_spec.js
@@ -68,6 +68,7 @@ define(['jquery', 'common/js/spec_helpers/template_helpers', 'js/verify_student/
beforeEach(function() {
window.analytics = jasmine.createSpyObj('analytics', ['track', 'page', 'trackLink']);
+ navigator.getUserMedia = jasmine.createSpy();
setFixtures('');
$.each( TEMPLATES, function( index, templateName ) {
diff --git a/lms/static/js/spec/verify_student/reverify_view_spec.js b/lms/static/js/spec/verify_student/reverify_view_spec.js
index b22236fb2b..e932ea116f 100644
--- a/lms/static/js/spec/verify_student/reverify_view_spec.js
+++ b/lms/static/js/spec/verify_student/reverify_view_spec.js
@@ -1,8 +1,9 @@
/**
* Tests for the reverification view.
**/
-define(['jquery', 'common/js/spec_helpers/template_helpers', 'js/verify_student/views/reverify_view'],
- function( $, TemplateHelpers, ReverifyView ) {
+define(['jquery', 'common/js/spec_helpers/template_helpers', 'js/verify_student/views/review_photos_step_view',
+ 'js/verify_student/views/reverify_view'],
+ function( $, TemplateHelpers, ReviewPhotosStepView, ReverifyView ) {
'use strict';
describe( 'edx.verify_student.ReverifyView', function() {
@@ -45,6 +46,7 @@ define(['jquery', 'common/js/spec_helpers/template_helpers', 'js/verify_student/
beforeEach(function() {
window.analytics = jasmine.createSpyObj('analytics', ['track', 'page', 'trackLink']);
+ navigator.getUserMedia = jasmine.createSpy();
setFixtures('');
$.each( TEMPLATES, function( index, templateName ) {
diff --git a/lms/static/js/spec/verify_student/review_photos_step_view_spec.js b/lms/static/js/spec/verify_student/review_photos_step_view_spec.js
index 59f07447f1..6ae60b7c01 100644
--- a/lms/static/js/spec/verify_student/review_photos_step_view_spec.js
+++ b/lms/static/js/spec/verify_student/review_photos_step_view_spec.js
@@ -42,7 +42,7 @@ define([
// Simulate the server response
if ( succeeds ) {
- AjaxHelpers.respondWithJson( requests );
+ AjaxHelpers.respondWithJson( requests, {} );
} else {
AjaxHelpers.respondWithTextError( requests, 400, SERVER_ERROR_MSG );
}
diff --git a/lms/static/js/spec/verify_student/webcam_photo_view_spec.js b/lms/static/js/spec/verify_student/webcam_photo_view_spec.js
index 8d734dfda4..1ef1322095 100644
--- a/lms/static/js/spec/verify_student/webcam_photo_view_spec.js
+++ b/lms/static/js/spec/verify_student/webcam_photo_view_spec.js
@@ -94,7 +94,7 @@ define([
var view = createView( new StubBackend( "html5" ) );
// Spy on the backend
- spyOn( view.backend, 'snapshot' ).andCallThrough();
+ spyOn( view.backend, 'snapshot' ).and.callThrough();
// Initially, only the snapshot button is shown
expectButtonShown({
@@ -125,7 +125,7 @@ define([
var view = createView( new StubBackend( "html5" ) );
// Spy on the backend
- spyOn( view.backend, 'reset' ).andCallThrough();
+ spyOn( view.backend, 'reset' ).and.callThrough();
// Take the snapshot, then reset
takeSnapshot();
diff --git a/lms/static/js/spec/views/fields_helpers.js b/lms/static/js/spec/views/fields_helpers.js
index 6248656d33..fc089d579f 100644
--- a/lms/static/js/spec/views/fields_helpers.js
+++ b/lms/static/js/spec/views/fields_helpers.js
@@ -118,7 +118,7 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
expectMessageContains(view, view.helpMessage);
view.showSuccessMessage();
expectMessageContains(view, view.indicators.success);
- jasmine.Clock.tick(7000);
+ jasmine.clock().tick(7000);
// Message gets reset
expectMessageContains(view, view.helpMessage);
@@ -126,7 +126,7 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
expectMessageContains(view, view.indicators.success);
// But if we change the message, it should not get reset.
view.showHelpMessage("Do not reset this!");
- jasmine.Clock.tick(7000);
+ jasmine.clock().tick(7000);
expectMessageContains(view, "Do not reset this!");
};
diff --git a/lms/static/js/spec/views/fields_spec.js b/lms/static/js/spec/views/fields_spec.js
index 3dd02806b8..0fd4810b21 100644
--- a/lms/static/js/spec/views/fields_spec.js
+++ b/lms/static/js/spec/views/fields_spec.js
@@ -25,7 +25,11 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
beforeEach(function () {
timerCallback = jasmine.createSpy('timerCallback');
- jasmine.Clock.useMock();
+ jasmine.clock().install();
+ });
+
+ afterEach(function() {
+ jasmine.clock().uninstall();
});
it("updates messages correctly for all fields", function() {
diff --git a/lms/static/js/student_account/account.js b/lms/static/js/student_account/account.js
index f8ad63d5e3..e05339663d 100644
--- a/lms/static/js/student_account/account.js
+++ b/lms/static/js/student_account/account.js
@@ -178,11 +178,15 @@ var edx = edx || {};
this.$passwordResetStatus
.removeClass('error')
.text("");
- },
+ }
});
- return new edx.student.account.AccountView({
- el: $('#account-container')
- }).render();
+ try {
+ new edx.student.account.AccountView({
+ el: $('#account-container')
+ }).render();
+ } catch (e) {
+ // TODO: handle exception
+ }
})(jQuery, _, Backbone, gettext);
diff --git a/lms/static/js_test.yml b/lms/static/js_test.yml
index 63b1aec2c2..e38db0e302 100644
--- a/lms/static/js_test.yml
+++ b/lms/static/js_test.yml
@@ -31,7 +31,6 @@ lib_paths:
- xmodule_js/common_static/js/test/i18n.js
- xmodule_js/common_static/coffee/src/ajax_prefix.js
- xmodule_js/common_static/js/src/logger.js
- - xmodule_js/common_static/js/vendor/jasmine-jquery.js
- xmodule_js/common_static/js/vendor/jasmine-imagediff.js
- xmodule_js/common_static/js/vendor/requirejs/require.js
- js/RequireJS-namespace-undefine.js
diff --git a/lms/static/js_test_coffee.yml b/lms/static/js_test_coffee.yml
index 34013670ca..82e1f58195 100644
--- a/lms/static/js_test_coffee.yml
+++ b/lms/static/js_test_coffee.yml
@@ -31,19 +31,21 @@ lib_paths:
- xmodule_js/common_static/js/test/i18n.js
- xmodule_js/common_static/coffee/src/ajax_prefix.js
- xmodule_js/common_static/js/src/logger.js
- - xmodule_js/common_static/js/vendor/jasmine-jquery.js
+ - xmodule_js/common_static/js/vendor/underscore-min.js
- xmodule_js/common_static/js/vendor/jasmine-imagediff.js
- xmodule_js/common_static/js/vendor/requirejs/require.js
- js/RequireJS-namespace-undefine.js
- - xmodule_js/common_static/js/vendor/jquery.min.js
- xmodule_js/common_static/js/vendor/jquery-ui.min.js
- xmodule_js/common_static/js/vendor/jquery.cookie.js
- xmodule_js/common_static/js/vendor/flot/jquery.flot.js
+ - xmodule_js/common_static/js/vendor/moment.min.js
+ - xmodule_js/common_static/js/vendor/moment-with-locales.min.js
- xmodule_js/common_static/js/vendor/CodeMirror/codemirror.js
- xmodule_js/common_static/js/vendor/URI.min.js
- xmodule_js/common_static/coffee/src/jquery.immediateDescendents.js
- xmodule_js/common_static/js/xblock
- xmodule_js/common_static/coffee/src/xblock
+ - moment_requirejs.js
- xmodule_js/src/capa/
- xmodule_js/src/video/
- xmodule_js/src/xmodule.js
@@ -75,7 +77,7 @@ fixture_paths:
# When loading many files, this can be slow, so
# exclude any files you don't need.
#exclude_from_page:
-# - path/to/lib/exclude/*
+# - coffee/spec/helper.js
# Regular expression used to guarantee that a *.js file
# is included in the test runner page.
diff --git a/lms/static/karma_lms.conf.js b/lms/static/karma_lms.conf.js
index 684323a9d2..453fbb0baa 100644
--- a/lms/static/karma_lms.conf.js
+++ b/lms/static/karma_lms.conf.js
@@ -30,11 +30,10 @@ var files = [
{pattern: 'xmodule_js/common_static/js/test/i18n.js', included: false},
{pattern: 'xmodule_js/common_static/coffee/src/ajax_prefix.js', included: false},
{pattern: 'xmodule_js/common_static/js/src/logger.js', included: false},
- {pattern: 'xmodule_js/common_static/js/vendor/jasmine-imagediff.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/requirejs/require.js', included: false},
{pattern: 'js/RequireJS-namespace-undefine.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/requirejs/text.js', included: false},
- {pattern: 'xmodule_js/common_static/js/vendor/jquery.min.js', included: false},
+ {pattern: 'xmodule_js/common_static/js/vendor/jquery.min.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/jquery-ui.min.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.simulate.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/jquery.cookie.js', included: false},
@@ -70,10 +69,9 @@ var files = [
{pattern: 'xmodule_js/common_static/js/vendor/moment.min.js', included: false},
{pattern: 'xmodule_js/common_static/js/vendor/moment-with-locales.min.js', included: false},
{pattern: 'xmodule_js/common_static/common/js/utils/edx.utils.validate.js', included: false},
- {pattern: 'xmodule_js/common_static/js/vendor/slick.core.js', included: false},
- {pattern: 'xmodule_js/common_static/js/vendor/slick.grid.js', included: false},
- {pattern: 'xmodule_js/common_static/js/vendor/jquery.event.drag-2.2.js', included: false},
- {pattern: 'xmodule_js/common_static/js/libs/jasmine-waituntil.js', included: true},
+ {pattern: 'xmodule_js/common_static/js/vendor/jquery.event.drag-2.2.js', included: true},
+ {pattern: 'xmodule_js/common_static/js/vendor/slick.core.js', included: true},
+ {pattern: 'xmodule_js/common_static/js/vendor/slick.grid.js', included: true},
// Paths to source JavaScript files
{pattern: 'js/**/*.js', included: false, nocache: true},
@@ -85,6 +83,10 @@ var files = [
{pattern: 'teams/js/**/*.js', included: false, nocache: true},
{pattern: 'xmodule_js/common_static/coffee/**/*.js', included: false, nocache: true},
+ // Paths to Jasmine plugins
+ {pattern: 'xmodule_js/common_static/js/libs/jasmine-waituntil.js', included: true},
+ {pattern: 'xmodule_js/common_static/js/libs/jasmine-extensions.js', included: true},
+
// Paths to spec (test) JavaScript files
{pattern: 'js/spec/**/*.js', included: false, nocache: true},
{pattern: 'teams/js/spec/**/*.js', included: false, nocache: true},
diff --git a/lms/static/karma_lms_coffee.conf.js b/lms/static/karma_lms_coffee.conf.js
index 410477b532..9b60807b75 100644
--- a/lms/static/karma_lms_coffee.conf.js
+++ b/lms/static/karma_lms_coffee.conf.js
@@ -38,6 +38,7 @@ var files = [
{pattern: 'xmodule_js/common_static/js/src/logger.js', included: true},
{pattern: 'xmodule_js/common_static/common/js/vendor/underscore.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/jasmine-imagediff.js', included: true},
+ {pattern: 'xmodule_js/common_static/js/libs/jasmine-extensions.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/requirejs/require.js', included: true},
{pattern: 'js/RequireJS-namespace-undefine.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/jquery-ui.min.js', included: true},
diff --git a/lms/templates/verify_student/webcam_photo.underscore b/lms/templates/verify_student/webcam_photo.underscore
index 30ceb58687..982c698f4c 100644
--- a/lms/templates/verify_student/webcam_photo.underscore
+++ b/lms/templates/verify_student/webcam_photo.underscore
@@ -10,7 +10,7 @@