Skip to content

Commit

Permalink
Added props validation for "tag" and unit test for it.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionel Bijaoui committed May 16, 2017
1 parent 90b0767 commit c728597
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/formGenerator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,12 @@ div
},
tag: {
type: String,
default: 'fieldset'
}
type: String,
default: "fieldset",
validator: function (value) {
return value.length > 0;
}
}
},
data () {
Expand Down
25 changes: 25 additions & 0 deletions test/unit/specs/VueFormGenerator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<vue-form-generator :schema="schema" ref="form" tag="div"></vue-form-generator>`,
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", () => {
Expand Down

0 comments on commit c728597

Please sign in to comment.