|
@@ -7,14 +7,14 @@ import {
|
|
} from '@formkit/core'
|
|
} from '@formkit/core'
|
|
import { FormKit } from '@formkit/vue'
|
|
import { FormKit } from '@formkit/vue'
|
|
import { renderComponent } from '@tests/support/components'
|
|
import { renderComponent } from '@tests/support/components'
|
|
-import addValuePopulatedDataAttribute from '../global/addValuePopulatedDataAttribute'
|
|
|
|
|
|
+import extendDataAttribues from '../global/extendDataAttributes'
|
|
|
|
|
|
const wrapperParameters = {
|
|
const wrapperParameters = {
|
|
form: true,
|
|
form: true,
|
|
formField: true,
|
|
formField: true,
|
|
}
|
|
}
|
|
|
|
|
|
-const renderKit = () => {
|
|
|
|
|
|
+const renderKit = (props: any = {}) => {
|
|
const kit = renderComponent(FormKit, {
|
|
const kit = renderComponent(FormKit, {
|
|
...wrapperParameters,
|
|
...wrapperParameters,
|
|
props: {
|
|
props: {
|
|
@@ -22,6 +22,7 @@ const renderKit = () => {
|
|
type: 'text',
|
|
type: 'text',
|
|
id: 'text',
|
|
id: 'text',
|
|
label: 'text',
|
|
label: 'text',
|
|
|
|
+ ...props,
|
|
},
|
|
},
|
|
})
|
|
})
|
|
return {
|
|
return {
|
|
@@ -30,7 +31,7 @@ const renderKit = () => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-describe('addValuePopulatedDataAttribute', () => {
|
|
|
|
|
|
+describe('extendDataAttributes - data-populated', () => {
|
|
describe('renders on output', () => {
|
|
describe('renders on output', () => {
|
|
const originalSchema = vi.fn()
|
|
const originalSchema = vi.fn()
|
|
const inputNode = createNode({
|
|
const inputNode = createNode({
|
|
@@ -50,7 +51,7 @@ describe('addValuePopulatedDataAttribute', () => {
|
|
})
|
|
})
|
|
|
|
|
|
test('applies schema on input', () => {
|
|
test('applies schema on input', () => {
|
|
- addValuePopulatedDataAttribute(inputNode)
|
|
|
|
|
|
+ extendDataAttribues(inputNode)
|
|
|
|
|
|
const schema = (inputNode.props.definition?.schema ||
|
|
const schema = (inputNode.props.definition?.schema ||
|
|
(() => ({}))) as FormKitExtendableSchemaRoot
|
|
(() => ({}))) as FormKitExtendableSchemaRoot
|
|
@@ -63,7 +64,7 @@ describe('addValuePopulatedDataAttribute', () => {
|
|
})
|
|
})
|
|
|
|
|
|
test('skips non-inputs', () => {
|
|
test('skips non-inputs', () => {
|
|
- addValuePopulatedDataAttribute({
|
|
|
|
|
|
+ extendDataAttribues({
|
|
...inputNode,
|
|
...inputNode,
|
|
type: 'list',
|
|
type: 'list',
|
|
})
|
|
})
|
|
@@ -89,3 +90,12 @@ describe('addValuePopulatedDataAttribute', () => {
|
|
})
|
|
})
|
|
})
|
|
})
|
|
})
|
|
})
|
|
|
|
+
|
|
|
|
+describe('extendDataAttributes - data-required', () => {
|
|
|
|
+ it('has data-required if field is required', () => {
|
|
|
|
+ const kit = renderKit({
|
|
|
|
+ required: true,
|
|
|
|
+ })
|
|
|
|
+ expect(kit.getOuterKit()).toHaveAttribute('data-required')
|
|
|
|
+ })
|
|
|
|
+})
|