Files
edx-platform/lms/static/js/spec/student_account/emailoptin_spec.js
stephensanchez 32c9230cd1 Hooking the logistration page into the new HTTP endpoint for email opt in.
Update the PR based on Code Review comments, and additional tests.

Using underscore js
2014-12-01 17:25:57 +00:00

29 lines
1.1 KiB
JavaScript

define(['js/common_helpers/ajax_helpers', 'js/student_account/emailoptin'],
function( AjaxHelpers, EmailOptInInterface ) {
'use strict';
describe( 'edx.student.account.EmailOptInInterface', function() {
var COURSE_KEY = 'edX/DemoX/Fall',
EMAIL_OPT_IN = 'True',
EMAIL_OPT_IN_URL = '/user_api/v1/preferences/email_opt_in/';
it('Opts in for organization emails', function() {
// Spy on Ajax requests
var requests = AjaxHelpers.requests( this );
// Attempt to enroll the user
EmailOptInInterface.setPreference( COURSE_KEY, EMAIL_OPT_IN );
// Expect that the correct request was made to the server
AjaxHelpers.expectRequest(
requests, 'POST', EMAIL_OPT_IN_URL, 'course_id=edX%2FDemoX%2FFall&email_opt_in=True'
);
// Simulate a successful response from the server
AjaxHelpers.respondWithJson(requests, {});
});
});
}
);