+
`
})
+
+ wrapper.vm.values = { test: '1234' }
+
await flushPromises()
- wrapper.vm.formValues = { test: '1234' }
- await flushPromises()
- expect(wrapper.find('input[type="text"]').element['value']).toBe('1234')
+
+ const input = wrapper.find('input[type="text"]')
+
+ expect(input).toBeTruthy()
+ expect(input.element['value']).toBe('1234')
})
it('Resolves hasValidationErrors to true', async () => {
diff --git a/test/unit/FormularioGrouping.test.js b/test/unit/FormularioGrouping.test.js
index 40448c7..7cb2818 100644
--- a/test/unit/FormularioGrouping.test.js
+++ b/test/unit/FormularioGrouping.test.js
@@ -53,7 +53,7 @@ describe('FormularioGrouping', () => {
`
}
})
- expect(wrapper.find('input[type="text"]').element.value).toBe('Group text')
+ expect(wrapper.find('input[type="text"]').element['value']).toBe('Group text')
})
it('Data reactive with grouped fields', async () => {
diff --git a/test/unit/FormularioInput.test.js b/test/unit/FormularioInput.test.js
index 8964f8b..3e18150 100644
--- a/test/unit/FormularioInput.test.js
+++ b/test/unit/FormularioInput.test.js
@@ -19,17 +19,17 @@ Vue.use(Formulario, {
})
describe('FormularioInput', () => {
- it('allows custom field-rule level validation strings', async () => {
+ it('Allows custom field-rule level validation strings', async () => {
const wrapper = mount(FormularioInput, {
propsData: {
name: 'test',
validation: 'required|in:abcdef',
- validationMessages: {in: 'the value was different than expected'},
+ validationMessages: { in: 'the value was different than expected' },
errorBehavior: 'live',
- value: 'other value'
+ value: 'other value',
},
scopedSlots: {
- default: `{{ error.message }}
`
+ default: `{{ violation.message }}
`
},
})
await flushPromises()
@@ -52,30 +52,33 @@ describe('FormularioInput', () => {
expect(wrapper.find('span').exists()).toBe(false)
})
- it('no validation on value change when errorBehavior is not live', async () => {
+ it('No validation on value change when errorBehavior is not live', async () => {
const wrapper = mount(FormularioInput, {
propsData: {
name: 'test',
validation: 'required|in:abcdef',
validationMessages: {in: 'the value was different than expected'},
errorBehavior: 'submit',
- value: 'other value'
+ value: 'Initial'
},
scopedSlots: {
default: `
- {{ error.message }}
+ {{ error.message }}
`
}
})
+
await flushPromises()
+
expect(wrapper.find('span').exists()).toBe(false)
- const input = wrapper.find('input[type="text"]')
- input.element.value = 'test'
- input.trigger('input')
+ wrapper.find('input[type="text"]').element['value'] = 'Test'
+ wrapper.find('input[type="text"]').trigger('change')
+
await flushPromises()
- expect(wrapper.find('input[type="text"]').element.value).toBe('test')
+
+ expect(wrapper.find('input[type="text"]').element['value']).toBe('Test')
expect(wrapper.find('span').exists()).toBe(false)
})
@@ -156,7 +159,7 @@ describe('FormularioInput', () => {
expect(wrapper.find('span').text()).toBe('failed the foobar check')
})
- it('uses global custom validation rules', async () => {
+ it('Uses global custom validation rules', async () => {
const wrapper = mount(FormularioInput, {
propsData: {
name: 'test',
@@ -169,7 +172,7 @@ describe('FormularioInput', () => {
expect(globalRule.mock.calls.length).toBe(1)
})
- it('emits correct validation event', async () => {
+ it('Emits correct validation event', async () => {
const wrapper = mount(FormularioInput, {
propsData: {
validation: 'required',
@@ -195,7 +198,7 @@ describe('FormularioInput', () => {
propsData: { name: 'test', validation: 'bail|required|in:xyz', errorBehavior: 'live' }
})
await flushPromises();
- expect(wrapper.vm.context.validationErrors.length).toBe(1);
+ expect(wrapper.vm.context.violations.length).toBe(1);
})
it('can show multiple validation errors if they occur before the bail rule', async () => {
@@ -203,7 +206,7 @@ describe('FormularioInput', () => {
propsData: { name: 'test', validation: 'required|in:xyz|bail', errorBehavior: 'live' }
})
await flushPromises();
- expect(wrapper.vm.context.validationErrors.length).toBe(2);
+ expect(wrapper.vm.context.violations.length).toBe(2);
})
it('can avoid bail behavior by using modifier', async () => {
@@ -211,7 +214,7 @@ describe('FormularioInput', () => {
propsData: { name: 'test', validation: '^required|in:xyz|min:10,length', errorBehavior: 'live', value: '123' }
})
await flushPromises();
- expect(wrapper.vm.context.validationErrors.length).toBe(2);
+ expect(wrapper.vm.context.violations.length).toBe(2);
})
it('prevents later error messages when modified rule fails', async () => {
@@ -219,7 +222,7 @@ describe('FormularioInput', () => {
propsData: { name: 'test', validation: '^required|in:xyz|min:10,length', errorBehavior: 'live' }
})
await flushPromises();
- expect(wrapper.vm.context.validationErrors.length).toBe(1);
+ expect(wrapper.vm.context.violations.length).toBe(1);
})
it('can bail in the middle of the rule set with a modifier', async () => {
@@ -227,7 +230,7 @@ describe('FormularioInput', () => {
propsData: { name: 'test', validation: 'required|^in:xyz|min:10,length', errorBehavior: 'live' }
})
await flushPromises();
- expect(wrapper.vm.context.validationErrors.length).toBe(2);
+ expect(wrapper.vm.context.violations.length).toBe(2);
})
it('does not show errors on blur when set error-behavior is submit', async () => {