diff --git a/test/unit/Formulario.test.js b/test/unit/Formulario.test.js
index 4cbb10f..04a1d03 100644
--- a/test/unit/Formulario.test.js
+++ b/test/unit/Formulario.test.js
@@ -3,60 +3,54 @@ import Formulario from '@/Formulario.ts'
import plugin from '@/index.ts'
describe('Formulario', () => {
- it('Installs on vue instance', () => {
+ it('installs on vue instance', () => {
const localVue = createLocalVue()
localVue.use(plugin)
+ expect(localVue.component('FormularioField')).toBeTruthy()
+ expect(localVue.component('FormularioFieldGroup')).toBeTruthy()
expect(localVue.component('FormularioForm')).toBeTruthy()
- expect(localVue.component('FormularioGrouping')).toBeTruthy()
- expect(localVue.component('FormularioInput')).toBeTruthy()
- const wrapper = mount({ template: '
', }, { localVue })
+ const wrapper = mount({ render: h => h('div'), }, { localVue })
expect(wrapper.vm.$formulario).toBeInstanceOf(Formulario)
})
- it ('Pushes Formulario instance to child a component', () => {
+ it ('pushes Formulario instance to child a component', () => {
const localVue = createLocalVue()
localVue.use(plugin)
- localVue.component('TestComponent', {
- render (h) {
- return h('div')
- }
+
+ const ChildComponent = localVue.component('ChildComponent', {
+ render: h => h('div'),
})
- const wrapper = mount({
- render (h) {
- return h('div', [h('TestComponent', { ref: 'test' })])
- },
+ const parent = mount({
+ render: h => h('div', [h('ChildComponent')]),
}, { localVue })
- expect(wrapper.vm.$formulario === wrapper.vm.$refs.test.$formulario).toBe(true)
+ const child = parent.findComponent(ChildComponent)
+
+ expect(parent.vm.$formulario === child.vm.$formulario).toBe(true)
})
- it ('Does not pushes Formulario instance to a child component, if it has its own', () => {
+ it ('does not push Formulario instance to a child component, if it has its own', () => {
const localVue = createLocalVue()
localVue.use(plugin)
// noinspection JSCheckFunctionSignatures
- localVue.component('TestComponent', {
- formulario () {
- return new Formulario()
- },
-
- render (h) {
- return h('div')
- },
+ const ChildComponent = localVue.component('ChildComponent', {
+ formulario: () => new Formulario(),
+ render: h => h('div'),
})
- const wrapper = mount({
- render (h) {
- return h('div', [h('TestComponent', { ref: 'test' })])
- },
+ const parent = mount({
+ render: h => h('div', [h('ChildComponent')]),
}, { localVue })
- expect(wrapper.vm.$formulario === wrapper.vm.$refs.test.$formulario).toBe(false)
+ const child = parent.findComponent(ChildComponent)
+
+ expect(parent.vm.$formulario === child.vm.$formulario).toBe(false)
})
})
diff --git a/test/unit/FormularioFieldGroup.test.js b/test/unit/FormularioFieldGroup.test.js
index 5de1c85..7f00156 100644
--- a/test/unit/FormularioFieldGroup.test.js
+++ b/test/unit/FormularioFieldGroup.test.js
@@ -85,11 +85,11 @@ describe('FormularioFieldGroup', () => {
},
slots: {
default: `
-
+
{{ error }}
-
+
`,
},
})
diff --git a/test/unit/FormularioForm.test.js b/test/unit/FormularioForm.test.js
index 0c6f3f8..ecb19d9 100644
--- a/test/unit/FormularioForm.test.js
+++ b/test/unit/FormularioForm.test.js
@@ -43,8 +43,8 @@ describe('FormularioForm', () => {
propsData: { formularioValue: {} },
slots: {
default: `
-
-
+
+
`
}
})
@@ -56,8 +56,8 @@ describe('FormularioForm', () => {
data: () => ({ active: true }),
template: `
-
-
+
+
`
})
@@ -73,14 +73,14 @@ describe('FormularioForm', () => {
data: () => ({ active: true, nested: { groups: { value: 'value' } }, groups: [{ name: 'group1' }, { name: 'group2' }] }),
template: `
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
`
})
@@ -100,9 +100,9 @@ describe('FormularioForm', () => {
propsData: { formularioValue: { test: 'Has initial value' } },
slots: {
default: `
-
+
-
+
`
}
})
@@ -115,9 +115,9 @@ describe('FormularioForm', () => {
propsData: { formularioValue: { test: 'has initial value' } },
slots: {
default: `
-
+
-
+
`
}
})
@@ -129,7 +129,7 @@ describe('FormularioForm', () => {
data: () => ({ values: {} }),
template: `
-
+
`
})
@@ -141,9 +141,9 @@ describe('FormularioForm', () => {
data: () => ({ values: { test: '' } }),
template: `
-
+
-
+
`
})
@@ -156,9 +156,9 @@ describe('FormularioForm', () => {
data: () => ({ formValues: { date: new Date(123) } }),
template: `
-
+
{{ context.model.getTime() }}
-
+
`
})
@@ -179,7 +179,7 @@ describe('FormularioForm', () => {
}),
template: `
-
+
`
})
@@ -194,7 +194,7 @@ describe('FormularioForm', () => {
formularioValue: { test: 'Initial' }
},
slots: {
- default: ''
+ default: ''
},
})
@@ -209,9 +209,9 @@ describe('FormularioForm', () => {
data: () => ({ values: { test: 'abcd' } }),
template: `
-
+
-
+
`
})
@@ -228,7 +228,7 @@ describe('FormularioForm', () => {
it('Resolves hasValidationErrors to true', async () => {
const wrapper = mount(FormularioForm, {
- slots: { default: '' }
+ slots: { default: '' }
})
wrapper.find('form').trigger('submit')
await flushPromises()
@@ -241,7 +241,7 @@ describe('FormularioForm', () => {
it('Resolves submitted form values to an object', async () => {
const wrapper = mount(FormularioForm, {
- slots: { default: '' }
+ slots: { default: '' }
})
wrapper.find('form').trigger('submit')
await flushPromises()
@@ -277,9 +277,9 @@ describe('FormularioForm', () => {
propsData: { errors: { fieldWithErrors: ['This field has an error'] }},
slots: {
default: `
-
+
{{ error }}
-
+
`
}
})
@@ -324,10 +324,10 @@ describe('FormularioForm', () => {
const wrapper = mount(FormularioForm, {
slots: {
default: `
-
+
-
-
+
+
`,
}
})
@@ -346,7 +346,7 @@ describe('FormularioForm', () => {
it('Emits correct validation event on entry', async () => {
const wrapper = mount(FormularioForm, {
slots: { default: `
- {
type="text"
@blur="context.runValidation()"
>
-
-
+
@@ -394,12 +394,12 @@ describe('FormularioForm', () => {
name="login"
ref="form"
>
-
+
-
-
+
+
-
+
`,
})
@@ -432,13 +432,13 @@ describe('FormularioForm', () => {
:errors="errors"
ref="form"
>
-
{{ error.message }}
-
+
`
})