From c728597647cd81d27b425fa3add67e084f1d360b Mon Sep 17 00:00:00 2001 From: Lionel Bijaoui Date: Tue, 16 May 2017 15:57:03 +0200 Subject: [PATCH] Added props validation for "tag" and unit test for it. --- src/formGenerator.vue | 9 ++++++--- test/unit/specs/VueFormGenerator.spec.js | 25 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/formGenerator.vue b/src/formGenerator.vue index c24ccbdf..4a379658 100644 --- a/src/formGenerator.vue +++ b/src/formGenerator.vue @@ -73,9 +73,12 @@ div }, tag: { - type: String, - default: 'fieldset' - } + type: String, + default: "fieldset", + validator: function (value) { + return value.length > 0; + } + } }, data () { diff --git a/test/unit/specs/VueFormGenerator.spec.js b/test/unit/specs/VueFormGenerator.spec.js index 56a23038..964f0e0a 100644 --- a/test/unit/specs/VueFormGenerator.spec.js +++ b/test/unit/specs/VueFormGenerator.spec.js @@ -46,6 +46,31 @@ describe("VueFormGenerator.vue", () => { expect(el.getElementsByTagName("fieldset")).to.be.length(1); }); + }); + + describe("with empty schema and custom tag", () => { + let schema = {}; + + beforeEach( () => { + let elm = document.createElement("div"); + vm = new Vue({ + // eslint-disable-next-line quotes + template: ``, + data: { + schema + } + }).$mount(elm); + + el = vm.$el; + + return [el, vm]; + }); + + it("should be create fieldset", () => { + expect(vm.$el).to.be.exist; + expect(el.getElementsByTagName("div")).to.be.length(1); + }); + }); describe("check form-group classes", () => {