Skip to content

Commit

Permalink
feat(ChildrenWithAge): add maximum possible value to joint-responsibi…
Browse files Browse the repository at this point in the history
…lity & daycare (#4219)
  • Loading branch information
langz authored Nov 5, 2024
1 parent 83f0b37 commit 9b9c517
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
.dnb-icon {
display: inline-block;

// sine we use vertical-align: top on the SVG
// since we use vertical-align: top on the SVG
// we have to move center the alignment here again
// else basic text afterwards will get aligned on top
vertical-align: middle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ function EditContainer({
tr.ChildrenWithAge.dayCareExpenses.required,
}}
minimum={1}
maximum={1000000}
decimalLimit={0}
allowNegative={false}
/>
Expand Down Expand Up @@ -174,6 +175,7 @@ function EditContainer({
tr.ChildrenWithAge.jointResponsibilityExpenses.required,
}}
minimum={1}
maximum={1000000}
decimalLimit={0}
allowNegative={false}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,55 @@ describe('ChildrenWithAge', () => {
expect(screen.queryByRole('alert')).not.toBeInTheDocument()
})

it('should not accept values over 1000000 as joint-responsibility expense', async () => {
render(
<ChildrenWithAge
enableAdditionalQuestions={['joint-responsibility']}
/>
)

await userEvent.click(document.querySelectorAll('button')[0])
await userEvent.click(document.querySelectorAll('button')[4])
await userEvent.type(document.querySelectorAll('input')[2], '10000001')

const input = document.querySelectorAll('.dnb-input__input')[2]

fireEvent.blur(input)

expect(screen.getByRole('alert')).toHaveTextContent(
nbNO['nb-NO'].NumberField.errorMaximum.replace(
'{maximum}',
'1000000'
)
)
})

it('should not accept values over 1000000 as daycare expense', async () => {
render(<ChildrenWithAge enableAdditionalQuestions={['daycare']} />)

await userEvent.click(document.querySelectorAll('button')[0])
await userEvent.click(document.querySelectorAll('button')[5])
await userEvent.type(document.querySelectorAll('input')[2], '10000001')

const input = document.querySelectorAll('.dnb-input__input')[2]

fireEvent.blur(input)

expect(screen.getByRole('alert')).toHaveTextContent(
nbNO['nb-NO'].NumberField.errorMaximum.replace(
'{maximum}',
'1000000'
)
)

expect(screen.getByRole('alert')).toHaveTextContent(
nbNO['nb-NO'].NumberField.errorMaximum.replace(
'{maximum}',
'1000000'
)
)
})

it('should show summary with Nei when hasChildren changes to false', async () => {
render(
<Form.Handler>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ exports[`ChildrenWithAge should match snapshot 1`] = `
aria-placeholder="0"
aria-required="true"
class="dnb-input__input"
id="id-rbq"
id="id-rdu"
inputmode="numeric"
name="id-rbq"
name="id-rdu"
type="text"
/>,
},
Expand Down Expand Up @@ -125,9 +125,9 @@ exports[`ChildrenWithAge should match snapshot 1`] = `
aria-placeholder="0"
aria-required="true"
class="dnb-input__input"
id="id-rbv"
id="id-re3"
inputmode="numeric"
name="id-rbv"
name="id-re3"
type="text"
/>,
},
Expand Down Expand Up @@ -331,7 +331,7 @@ exports[`ChildrenWithAge should match snapshot 1`] = `
aria-valuenow="2"
aria-valuetext="2"
class="dnb-input__input"
id="id-rbg"
id="id-rdk"
inputmode="numeric"
name="countChildren"
role="spinbutton"
Expand Down

0 comments on commit 9b9c517

Please sign in to comment.