1
0
mirror of synced 2024-11-25 23:06:02 +03:00

test: Test logic refactor

This commit is contained in:
Zaytsev Kirill 2021-05-30 11:56:23 +03:00
parent 509aa44710
commit 0cba9e56b3

View File

@ -19,21 +19,18 @@ describe('FormularioFieldGroup', () => {
<input type="text" v-model="context.model"> <input type="text" v-model="context.model">
</FormularioField> </FormularioField>
</FormularioFieldGroup> </FormularioFieldGroup>
` `,
} },
}) })
expect(wrapper.findAll('input[type="text"]').length).toBe(1) wrapper.find('input').setValue('test')
wrapper.find('input[type="text"]').setValue('test')
wrapper.find('form').trigger('submit') wrapper.find('form').trigger('submit')
await flushPromises() await flushPromises()
const emitted = wrapper.emitted() expect(wrapper.emitted('submit')).toEqual([
[{ group: { text: 'test' } }],
expect(emitted['submit']).toBeTruthy() ])
expect(emitted['submit']).toEqual([[{ group: { text: 'test' } }]])
}) })
test('grouped fields to be got', async () => { test('grouped fields to be got', async () => {
@ -51,10 +48,11 @@ describe('FormularioFieldGroup', () => {
<input type="text" v-model="context.model"> <input type="text" v-model="context.model">
</FormularioField> </FormularioField>
</FormularioFieldGroup> </FormularioFieldGroup>
` `,
} },
}) })
expect(wrapper.find('input[type="text"]').element['value']).toBe('Group text')
expect(wrapper.find('input').element['value']).toBe('Group text')
}) })
test('data reactive with grouped fields', async () => { test('data reactive with grouped fields', async () => {
@ -69,12 +67,12 @@ describe('FormularioFieldGroup', () => {
</FormularioField> </FormularioField>
</FormularioFieldGroup> </FormularioFieldGroup>
</FormularioForm> </FormularioForm>
` `,
}) })
expect(wrapper.find('span').text()).toBe('') expect(wrapper.find('span').text()).toBe('')
wrapper.find('input[type="text"]').setValue('test') wrapper.find('input').setValue('test')
await flushPromises() await flushPromises()
@ -94,6 +92,7 @@ describe('FormularioFieldGroup', () => {
`, `,
}, },
}) })
expect(wrapper.findAll('span').length).toBe(1) expect(wrapper.findAll('span').length).toBe(1)
}) })
}) })