Commit 742758ee by Muhammad Shoaib

proctored exam add allowance views jasmine tests

parent b6e720b4
describe('ProctoredExamAddAllowanceView', function () { describe('ProctoredExamAddAllowanceView', function () {
var html = ''; var html = '';
var allowancesHtml = ''; var allowancesHtml = '';
var errorAddingAllowance = [{ var errorAddingAllowance = {
detail: "Cannot find user against asd" detail: "Cannot find user"
}]; };
var expectedProctoredAllowanceJson = [ var expectedProctoredAllowanceJson = [
{ {
created: "2015-08-10T09:15:45Z", created: "2015-08-10T09:15:45Z",
...@@ -306,11 +306,11 @@ describe('ProctoredExamAddAllowanceView', function () { ...@@ -306,11 +306,11 @@ describe('ProctoredExamAddAllowanceView', function () {
); );
//select the form values //select the form values
// invalid user_info returns error
$('#proctored_exam').val('Test Exam'); $('#proctored_exam').val('Test Exam');
$('#allowance_type').val('Additional time (minutes)'); $('#allowance_type').val('Additional time (minutes)');
$('#allowance_value').val('asdasdasdsa'); $('#allowance_value').val('2');
$("#user_info").val('testuser1'); $("#user_info").val('testuser112321');
// trigger the add allowance event. // trigger the add allowance event.
var spyEvent = spyOnEvent('form', 'submit'); var spyEvent = spyOnEvent('form', 'submit');
...@@ -320,9 +320,20 @@ describe('ProctoredExamAddAllowanceView', function () { ...@@ -320,9 +320,20 @@ describe('ProctoredExamAddAllowanceView', function () {
this.server.respond(); this.server.respond();
this.server.respond(); this.server.respond();
expect(this.proctored_exam_allowance.$el.find('tr.allowance-items').html()).toContain('testuser1'); expect(add_allowance_view.$el.find('.error-response').html()).toContain('Cannot find user');
expect(this.proctored_exam_allowance.$el.find('tr.allowance-items').html()).toContain('testuser1@test.com');
expect(this.proctored_exam_allowance.$el.find('tr.allowance-items').html()).toContain('Additional time (minutes)'); //select the form values
expect(this.proctored_exam_allowance.$el.find('tr.allowance-items').html()).toContain('Test Exam'); // empty value returns error
$('#proctored_exam').val('Test Exam');
$('#allowance_type').val('Additional time (minutes)');
$('#allowance_value').val('');
$("#user_info").val('testuser1');
// trigger the add allowance event.
var spyEvent = spyOnEvent('form', 'submit');
$('form').trigger( "submit" );
expect(add_allowance_view.$el.find('.error-message').html()).toContain('Required field');
}); });
}); });
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