Commit 02c30b77 by Clinton Blackburn

Merge pull request #278 from edx/clintonb/js-view-tests

Added additional JS tests
parents a34dcb75 63b6a5e5
......@@ -146,6 +146,9 @@
"gettext",
// App-specific
"analytics"
"analytics",
// Jasmine
"done"
]
}
define([
'models/course_seats/course_seat',
'views/course_seat_form_fields/course_seat_form_field_view'
],
function (CourseSeat,
CourseSeatFormFieldView) {
'use strict';
var model, view;
beforeEach(function () {
model = new CourseSeat();
view = new CourseSeatFormFieldView({model: model});
});
describe('cleanIdVerificationRequired', function () {
it('should always return a boolean', function () {
expect(view.cleanIdVerificationRequired('false')).toEqual(false);
expect(view.cleanIdVerificationRequired('true')).toEqual(true);
});
});
}
);
define([
'underscore',
'models/course_seats/professional_seat',
'views/course_seat_form_fields/professional_course_seat_form_field_view'
],
function (_,
ProfessionalSeat,
CourseSeatFormFieldView) {
'use strict';
var model, view;
beforeEach(function () {
model = new ProfessionalSeat();
view = new CourseSeatFormFieldView({model: model}).render();
});
describe('getFieldValue', function () {
it('should return a boolean if the name is id_verification_required', function () {
var values = [true, false];
// Sanity check for the default values
expect(model.get('id_verification_required')).toEqual(false);
expect(view.getFieldValue('id_verification_required')).toEqual(false);
_.each(values, function (value) {
model.set('id_verification_required', value);
// Wait for backbone.stickit to update the DOM
setTimeout(function () {
expect(view.getFieldValue('id_verification_required')).toEqual(value);
done();
}, 1);
});
});
it('should always return professional if the name is certificate_type', function () {
expect(view.getFieldValue('certificate_type')).toEqual('professional');
});
});
}
);
define([
'models/course_seats/verified_seat',
'views/course_seat_form_fields/verified_course_seat_form_field_view'
],
function (VerifiedSeat,
VerifiedCourseSeatFormFieldView) {
'use strict';
var model, view;
beforeEach(function () {
model = new VerifiedSeat();
view = new VerifiedCourseSeatFormFieldView({model: model}).render();
});
describe('getData', function () {
it('should return the data from the DOM/model', function () {
var data = {
certificate_type: 'verified',
id_verification_required: 'true',
price: '100',
expires: ''
};
expect(view.getData()).toEqual(data);
});
});
}
);
......@@ -39,6 +39,7 @@ define([
},
initialize: function () {
/* istanbul ignore next */
Backbone.Validation.bind(this, {
valid: function (view, attr) {
var $el = view.$('[name=' + attr + ']'),
......
define([
'underscore.string',
'views/course_seat_form_fields/verified_course_seat_form_field_view',
'text!templates/professional_course_seat_form_field.html'
'text!templates/professional_course_seat_form_field.html',
'backbone.super'
],
function (_s,
VerifiedCourseSeatFormFieldView,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment