let formGroup = createFormGroup(sectionIdStr, field);
let expectedHTML = `<divclass="form-group row"><labelclass="col-sm-4 col-form"for="section-1-after_trip">Have you taken this trip already?: </label><divclass="col-sm-6"><selectname="after_trip"id="section-1-after_trip"class="form-control"><optionvalue="true">Yes</option><optionvalue="false"selected="selected">No</option></select></div></div>`
let formGroup = createFormGroup(sectionIdStr, field);
let expectedHTML = `<divclass="form-group row"><labelclass="col-sm-4 col-form"for="section-1-after_trip">Have you taken this trip already?: </label><divclass="col-sm-6"><selectname="after_trip"id="section-1-after_trip"class="form-control"><optionvalue="true"selected="selected">Yes</option><optionvalue="false">No</option></select></div></div>`
// END: Test rendering of fields with type decimal
// BEGIN: Test rendering of fields with type integer
QUnit.test("integer input group renders", function(assert) {
let sectionIdStr = "section-1-";
let field = {
"value": 0,
"field_type": "integer",
"label": "Number of full days of travel",
"field_name": "full_days"
};
let formGroup = createFormGroup(sectionIdStr, field);
let expectedHTML = `<divclass="form-group row"><labelclass="col-sm-4 col-form"for="section-1-full_days">Number of full days of travel: </label><divclass="col-sm-6"><inputname="full_days"id="section-1-full_days"type="number"class="form-control"step="1"min="0"></div></div>`
// END: Test rendering of fields with type integer
// BEGIN: Test rendering of fields with type file
QUnit.test("file input group renders", function(assert) {
let sectionIdStr = "section-1-";
let field = {
"value": "",
"field_type": "file",
"label": "Screenshot of invoice",
"field_name": "invoice_screenshot"
};
let formGroup = createFormGroup(sectionIdStr, field);
let expectedHTML = `<divclass="form-group row"><labelclass="col-sm-4 col-form"for="section-1-invoice_screenshot">Screenshot of invoice: </label><divclass="col-sm-6"><inputname="invoice_screenshot"id="section-1-invoice_screenshot"type="file"class="form-control-file"><pclass="form-text"></p></div></div>`
let sectionDescription = "<p>Section Description</p>";
let sectionCompleted = false;
let ruleViolations = [];
let collapseDiv = createCollapsibleCardBody(form, sectionIdStr, sectionDescription, sectionCompleted, ruleViolations);
let expectedHTML = `<divid="section-1-collapse"class="collapse show"><divclass="card-body"><divclass="alert alert-danger section-alert">This section is not complete</div><p>Section Description</p><form></form></div></div>`;
assert.deepEqual(collapseDiv.outerHTML, expectedHTML, "collapseDiv html and expectedHTML are identical");
});
QUnit.test("complete section with no rule violations renders", function(assert) {
let form = document.createElement("form");
let sectionIdStr = "section-1-";
let sectionDescription = "<p>Section Description</p>";
let sectionCompleted = true;
let ruleViolations = [];
let collapseDiv = createCollapsibleCardBody(form, sectionIdStr, sectionDescription, sectionCompleted, ruleViolations);
let expectedHTML = `<divid="section-1-collapse"class="collapse"><divclass="card-body"><div></div><p>Section Description</p><form></form></div></div>`;
assert.deepEqual(collapseDiv.outerHTML, expectedHTML, "collapseDiv html and expectedHTML are identical");
});
QUnit.test("complete section with rule violation renders", function(assert) {
let form = document.createElement("form");
let sectionIdStr = "section-1-";
let sectionDescription = "<p>Section Description</p>";
let sectionCompleted = true;
let ruleViolations = [{"label": "Fare limits", "rule_break_text": "You did a bad thing"}]
let collapseDiv = createCollapsibleCardBody(form, sectionIdStr, sectionDescription, sectionCompleted, ruleViolations);
let expectedHTML = `<divid="section-1-collapse"class="collapse show"><divclass="card-body"><div></div><p>Section Description</p><form></form></div></div>`;
assert.deepEqual(collapseDiv.outerHTML, expectedHTML, "collapseDiv html and expectedHTML are identical");
QUnit.test("card footer no rule violations does not render", function(assert) {
let ruleViolations = [];
let cardFooter = createCardFooter(ruleViolations);
assert.strictEqual(cardFooter, null, "cardFooter is null");
});
QUnit.test("card footer with one rule violation renders", function(assert) {
let ruleViolations = [{"label": "Fare limits", "rule_break_text": "You did a bad thing"}];
let cardFooter = createCardFooter(ruleViolations);
let expectedHTML = `<divclass="card-footer"><divclass="alert alert-danger"><divclass="alert-heading">Rule Violations</div><hr><p><strong>Fare limits</strong><br>You did a bad thing</p></div></div>`;
assert.deepEqual(cardFooter.outerHTML, expectedHTML, "cardFooter html and expectedHTML are identical");
});
QUnit.test("card footer with multiple rule violation renders", function(assert) {
let ruleViolations = [{"label": "Fare limits", "rule_break_text": "You did a bad thing"}, {"label": "Fare limits", "rule_break_text": "Now you've done it"}];
let cardFooter = createCardFooter(ruleViolations);
let expectedHTML = `<divclass="card-footer"><divclass="alert alert-danger"><divclass="alert-heading">Rule Violations</div><hr><p><strong>Fare limits</strong><br>You did a bad thing</p><p><strong>Fare limits</strong><br>Now you've done it</p></div></div>`;
assert.deepEqual(cardFooter.outerHTML, expectedHTML, "cardFooter html and expectedHTML are identical");