Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests for initialValues for Checkbox component #380

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cypress/integration/basics/InitialValues.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ describe('Initial values', function() {
it('Takes "fieldProps.initialValue" as the highest priority', () => {
cy.getField('firstName').hasValue('John')
cy.getField('houseNumber').hasValue('4')
cy.getField('equalToBilling').hasValue(true)
})

it('Takes "Form.props.initialValues"', () => {
cy.getField('username')
.hasValue(initialValues.username)
.expected()

cy.getField('equalToBilling')
.hasValue(initialValues.deliveryAddress.equalToBilling)

cy.get('#billing-street').hasValue(initialValues.billingAddress.street)

cy.get('#delivery-street').hasValue(initialValues.deliveryAddress.street)
Expand Down
7 changes: 7 additions & 0 deletions examples/basics/InitialValues.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import { fieldPresets, createField, Form, Field } from 'react-advanced-form'
import { Input } from '@examples/fields'
import { Select } from '@examples/fields/Select'
import { Checkbox } from '@examples/fields/Checkbox'
import Button from '@examples/shared/Button'

export const initialValues = {
Expand All @@ -12,6 +13,7 @@ export const initialValues = {
},
deliveryAddress: {
street: 'Sunwell ave.',
equalToBilling: true
},
}

Expand Down Expand Up @@ -45,6 +47,11 @@ export default class InitialValues extends React.Component {
</Field.Group>

<Field.Group name="deliveryAddress">
<Checkbox
id="equalToBilling"
name="equalToBilling"
label="Is equal to billing address"
/>
<Input
id="delivery-street"
name="street"
Expand Down