/// import {assert} from 'chai'; import * as chai from 'chai'; import {FormResult_to_Model} from "./form.projections"; import {ServerFactory} from "./form.server.records"; import {FormDefinition} from "./form.client.models"; chai.should(); describe('FormResult_to_Model', () => { it('projects a blank record properly', () => { var form = ServerFactory.formDefinitionRecord(); const projected = FormResult_to_Model(form) as FormDefinition; assert.isNull(projected.meta.formId, 'The default value of formId is null.'); }); it('projects a real server model w/out failing', () => { const response = { "meta": { "formId": "the id", "instanceId": "the instance", "title": "Untitled Form" }, "sections": [ { "meta": { "sectionId": "the section id", "title": "Untitled Section", "layout": "simple" }, "layout": [ { "Name": "first-name", "Type": "text", "Label": "My Name", "Required": true, "Options": null }, { "Name": "middle-name", "Type": "text", "Label": "Middle Name", "Required": false, "Options": null }, { "Name": "last-name", "Type": "text", "Label": "Last Name", "Required": true, "Options": null }, { "Name": "birthdate", "Type": "date", "Label": "Birthdate", "Required": true, "Options": null }, { "Name": "suffix", "Type": "dropdown-single", "Label": "Suffix", "Required": false, "Options": [ { "Label": "Jr.", "Value": "Jr." }, { "Label": "Sr.", "Value": "S" }, { "Label": "III", "Value": "3" } ] } ] } ] }; FormResult_to_Model(response) as FormDefinition; }); });