I have the following karma test. But I get the error "EXPECTED: {"data":{"form_field_17":"None Required","title":"Mr","firstName":"John","lastName":"Doe","email":"[email protected]","mobile":"1114269874","registration":"123","form_field_15":"Test","pref_date":"2016-08-30T02:13:00.000Z"},"formId":4} GOT: {"data":"{"form_field_17":"None Required","title":"Mr","firstName":"John","lastName":"Doe","email":"[email protected]","mobile":"1114269874","registration":"123","form_field_15":"Test","pref_date":"30/08/2016 12:13 PM"}","formId":4}
Why does my JSON object have backslashes and my pref_date has changed format?
describe('when submitting a form', function () {
it('should be successful', function () {
var d = {
form_field_17: "None Required",
title: "Mr",
firstName: "John",
lastName: "Doe",
email: "[email protected]",
mobile: "1114269874",
registration: "123",
form_field_15: "Test",
pref_date: "2016-08-30T02:13:00.000Z"
};
$httpBackend.expect('POST', '/DynamicForm/SubmitForm/', { data: d, formId: 4})
.respond(200, "[{ success : 'true', data : 'true' }]");
DynamicFormFactory.SubmitForm(d, 4)
.then(function (data) {
expect(data.success).toBeTruthy();
});
$httpBackend.flush();
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
});
});
