Fixes #6
This commit is contained in:
parent
c6eae3493b
commit
192a2cd93b
2
dist/formulate.esm.js
vendored
2
dist/formulate.esm.js
vendored
File diff suppressed because one or more lines are too long
6
dist/formulate.min.js
vendored
6
dist/formulate.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/formulate.umd.js
vendored
2
dist/formulate.umd.js
vendored
File diff suppressed because one or more lines are too long
@ -108,7 +108,17 @@ export default {
|
|||||||
Object.assign(this.internalFormModelProxy, { [field]: value })
|
Object.assign(this.internalFormModelProxy, { [field]: value })
|
||||||
this.$emit('input', Object.assign({}, this.internalFormModelProxy))
|
this.$emit('input', Object.assign({}, this.internalFormModelProxy))
|
||||||
},
|
},
|
||||||
|
getUniqueRegistryName (base, count = 0) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(this.registry, base + (count || ''))) {
|
||||||
|
return this.getUniqueRegistryName(base, count + 1)
|
||||||
|
}
|
||||||
|
return base + (count || '')
|
||||||
|
},
|
||||||
register (field, component) {
|
register (field, component) {
|
||||||
|
// Don't re-register fields... @todo come up with another way of handling this that doesn't break multi option
|
||||||
|
if (Object.prototype.hasOwnProperty.call(this.registry, field)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
this.registry[field] = component
|
this.registry[field] = component
|
||||||
const hasVModelValue = Object.prototype.hasOwnProperty.call(component.$options.propsData, 'formulateValue')
|
const hasVModelValue = Object.prototype.hasOwnProperty.call(component.$options.propsData, 'formulateValue')
|
||||||
const hasValue = Object.prototype.hasOwnProperty.call(component.$options.propsData, 'value')
|
const hasValue = Object.prototype.hasOwnProperty.call(component.$options.propsData, 'value')
|
||||||
|
@ -210,4 +210,15 @@ describe('FormulateForm', () => {
|
|||||||
expect(wrapper.find('input[type="text"]').element.value).toBe('Dave Barnett')
|
expect(wrapper.find('input[type="text"]').element.value).toBe('Dave Barnett')
|
||||||
expect(wrapper.find('input[type="checkbox"]').element.checked).toBe(true)
|
expect(wrapper.find('input[type="checkbox"]').element.checked).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('shows error messages when it includes a checkbox with options', async () => {
|
||||||
|
const wrapper = mount(FormulateForm, {
|
||||||
|
propsData: { formulateValue: { box3: [] } },
|
||||||
|
slots: { default: '<FormulateInput type="checkbox" name="box3" validation="required" :options="{first: \'First\', second: \'Second\', third: \'Third\'}" />' }
|
||||||
|
})
|
||||||
|
wrapper.trigger('submit')
|
||||||
|
await wrapper.vm.$nextTick()
|
||||||
|
await flushPromises()
|
||||||
|
expect(wrapper.find('.formulate-input-error').exists()).toBe(true)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -140,27 +140,27 @@ describe('FormulateInputBox', () => {
|
|||||||
expect(wrapper.vm.radioValue).toBe('')
|
expect(wrapper.vm.radioValue).toBe('')
|
||||||
})
|
})
|
||||||
|
|
||||||
// it('does not pre-set internal value of FormulateForm when type "radio" with options', async () => {
|
it('does not pre-set internal value of FormulateForm when type "radio" with options', async () => {
|
||||||
// const wrapper = mount({
|
const wrapper = mount({
|
||||||
// data () {
|
data () {
|
||||||
// return {
|
return {
|
||||||
// radioValue: '',
|
radioValue: '',
|
||||||
// formValues: {},
|
formValues: {},
|
||||||
// options: {foo: 'Foo', bar: 'Bar', fooey: 'Fooey'}
|
options: {foo: 'Foo', bar: 'Bar', fooey: 'Fooey'}
|
||||||
// }
|
}
|
||||||
// },
|
},
|
||||||
// template: `
|
template: `
|
||||||
// <FormulateForm
|
<FormulateForm
|
||||||
// v-model="formValues"
|
v-model="formValues"
|
||||||
// >
|
>
|
||||||
// <FormulateInput type="radio" v-model="radioValue" name="foobar" :options="options" />
|
<FormulateInput type="radio" v-model="radioValue" name="foobar" :options="options" />
|
||||||
// </FormulateForm>
|
</FormulateForm>
|
||||||
// `
|
`
|
||||||
// })
|
})
|
||||||
// await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
// await flushPromises()
|
await flushPromises()
|
||||||
// expect(wrapper.vm.formValues.foobar).toBe(undefined)
|
expect(wrapper.vm.formValues.foobar).toBe('')
|
||||||
// })
|
})
|
||||||
|
|
||||||
it('does precheck the correct input when radio with options', async () => {
|
it('does precheck the correct input when radio with options', async () => {
|
||||||
const wrapper = mount({
|
const wrapper = mount({
|
||||||
|
Loading…
Reference in New Issue
Block a user