Commit 99a3c4e0 authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files

Fixed bad code introduced in earlier commits. Updated jasmine tests for Form.js.

parent 02fd569a
...@@ -31,7 +31,7 @@ var QfqNS = QfqNS || {}; ...@@ -31,7 +31,7 @@ var QfqNS = QfqNS || {};
throw new Error("Form '" + formId + "' does not exist."); throw new Error("Form '" + formId + "' does not exist.");
} }
this.formChanged = formChanged || false; this.formChanged = !!formChanged;
this.$form = $(document.forms[this.formId]); this.$form = $(document.forms[this.formId]);
this.$form.on("change", this.changeHandler.bind(this)); this.$form.on("change", this.changeHandler.bind(this));
this.$form.on("invalid.bs.validator", this.validationError.bind(this)); this.$form.on("invalid.bs.validator", this.validationError.bind(this));
...@@ -60,7 +60,7 @@ var QfqNS = QfqNS || {}; ...@@ -60,7 +60,7 @@ var QfqNS = QfqNS || {};
}; };
n.Form.prototype.getFormChanged = function () { n.Form.prototype.getFormChanged = function () {
return this.formChanged || this.ignoreChangeState; return this.formChanged;
}; };
n.Form.prototype.markChanged = function () { n.Form.prototype.markChanged = function () {
......
...@@ -39,6 +39,16 @@ describe("Form", function () { ...@@ -39,6 +39,16 @@ describe("Form", function () {
expect(form.getFormChanged()).toBe(false); expect(form.getFormChanged()).toBe(false);
}); });
it("should have formChanged() == false upon explicit initialization", function () {
form = new QfqNS.Form("myForm", false);
expect(form.getFormChanged()).toBe(false);
});
it("should have formChanged() == true upon explicit initialization", function () {
form = new QfqNS.Form("myForm", true);
expect(form.getFormChanged()).toBe(true);
});
it("should set the proper state upon form state change", function () { it("should set the proper state upon form state change", function () {
expect(form.getFormChanged()).toBe(false); expect(form.getFormChanged()).toBe(false);
$('#firstname').change(); $('#firstname').change();
......
Supports Markdown
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