Skip to content

Commit

Permalink
Merge branch 'master' into feature/vue-2.5.9
Browse files Browse the repository at this point in the history
* master:
  fix bower.json validation
  updated tests for modified label logic
  don't render labels when no label text is provided, proposed option 1 from vue-generators#347
  • Loading branch information
zoul0813 committed Dec 5, 2017
2 parents cf90bd6 + 776aff1 commit 1cb15d8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dist/vfg.js",
"dist/vfg.css",
"dist/vfg-core.js",
"dist/vfg-core.css",
"dist/vfg-core.css"
],
"moduleType": [
"amd"
Expand Down
2 changes: 2 additions & 0 deletions src/formGenerator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ div.vue-form-generator(v-if='schema != null')
// Should field type have a label?
fieldTypeHasLabel(field) {
if(isNil(field.label)) return false;
let relevantType = "";
if (field.type === "input") {
relevantType = field.inputType;
Expand Down
21 changes: 16 additions & 5 deletions test/unit/specs/VueFormGenerator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1095,20 +1095,31 @@ describe("VueFormGenerator.vue", () => {
});

it("should return true", () => {
expect(form.fieldTypeHasLabel({ type: "input", inputType: "checkbox"})).to.be.true;
expect(form.fieldTypeHasLabel({ type: "input", inputType: "text"})).to.be.true;
expect(form.fieldTypeHasLabel({ type: "checklist" })).to.be.true;
expect(form.fieldTypeHasLabel({ type: "input", inputType: "image"})).to.be.true;
expect(form.fieldTypeHasLabel({ type: "input", inputType: "checkbox", label: "checkbox"})).to.be.true;
expect(form.fieldTypeHasLabel({ type: "input", inputType: "text", label: "text"})).to.be.true;
expect(form.fieldTypeHasLabel({ type: "checklist",label: "checklist"})).to.be.true;
expect(form.fieldTypeHasLabel({ type: "input", inputType: "image", label: "image"})).to.be.true;
});

it("should return false", () => {
// with label text defined
expect(form.fieldTypeHasLabel({ type: "input", inputType: "button", label: "button"})).to.be.false;
expect(form.fieldTypeHasLabel({ type: "input", inputType: "submit", label: "submit"})).to.be.false;
expect(form.fieldTypeHasLabel({ type: "input", inputType: "reset", label: "reset"})).to.be.false;

// without label text defined
expect(form.fieldTypeHasLabel({ type: "input", inputType: "checkbox"})).to.be.false;
expect(form.fieldTypeHasLabel({ type: "input", inputType: "text"})).to.be.false;
expect(form.fieldTypeHasLabel({ type: "checklist"})).to.be.false;
expect(form.fieldTypeHasLabel({ type: "input", inputType: "image"})).to.be.false;
expect(form.fieldTypeHasLabel({ type: "input", inputType: "button"})).to.be.false;
expect(form.fieldTypeHasLabel({ type: "input", inputType: "submit"})).to.be.false;
expect(form.fieldTypeHasLabel({ type: "input", inputType: "reset"})).to.be.false;
});

it("should default to true for unknown types", () => {
expect(form.fieldTypeHasLabel({ type: "input", inputType: "unsupported-or-unknown"})).to.be.true;
expect(form.fieldTypeHasLabel({ type: "input", inputType: "unsupported-or-unknown", label:"unsupported"})).to.be.true;
expect(form.fieldTypeHasLabel({ type: "input", inputType: "unsupported-or-unknown"})).to.be.false;
});
});

Expand Down

0 comments on commit 1cb15d8

Please sign in to comment.