-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow html inside formFields props
- Loading branch information
Showing
5 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import Helpers from 'mwangaben-vthelpers' | ||
import VeeValidate from 'vee-validate' | ||
import { mount, createLocalVue } from '@vue/test-utils' | ||
import Form from '@/components/Form' | ||
import fields from './fields' | ||
|
||
const v = new VeeValidate.Validator() | ||
const localVue = createLocalVue() | ||
localVue.use(VeeValidate) | ||
|
||
let wrapper, b | ||
|
||
const FORM_NAME = 'testFormName' | ||
const fakeSlot = '[data-test=htmlContentFromFormFields]' | ||
|
||
describe('Fake slot', () => { | ||
beforeEach(() => { | ||
wrapper = mount(Form, { | ||
localVue, | ||
provide: () => ({ | ||
$validator: v | ||
}), | ||
propsData: { | ||
formFields: fields, | ||
formName: FORM_NAME | ||
} | ||
}) | ||
b = new Helpers(wrapper) | ||
}) | ||
|
||
afterEach(() => { | ||
wrapper.destroy() | ||
}) | ||
|
||
it('does not have fake slot if no key html in json', async () => { | ||
wrapper.setProps({ formFields: [ { label: 'x' }, [{ label: 'y' }, { label: 'z' }] ] }) | ||
await wrapper.vm.$nextTick() | ||
|
||
b.domHasNot(fakeSlot) | ||
}) | ||
|
||
it('show fake slot if html key is defined in json', async () => { | ||
const fakeSlotContent = 'this is a fake slot' | ||
|
||
wrapper.setProps({ formFields: [{ html: `<p>${fakeSlotContent}</p>` }] }) | ||
await wrapper.vm.$nextTick() | ||
|
||
b.domHas(fakeSlot) | ||
b.see(fakeSlotContent) | ||
|
||
const allParagraphs = wrapper.findAll('form > div p') | ||
expect(allParagraphs).toHaveLength(1) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
import Form from './Form' | ||
|
||
export default Form | ||
export { default } from './Form' |