Skip to content

Commit

Permalink
fix(FormStatus): fix stretch when used in Dropdown and Autocomplete (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker authored Oct 10, 2022
1 parent b5f11ac commit a961feb
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2380,7 +2380,6 @@ legend.dnb-form-label {
.dnb-dropdown__inner {
display: inline-flex;
flex-direction: column;
align-items: flex-start;
margin: 0;
padding: 0;
width: auto;
Expand Down Expand Up @@ -2834,7 +2833,6 @@ legend.dnb-form-label {
.dnb-autocomplete__inner {
display: inline-flex;
flex-direction: column;
align-items: flex-start;
margin: 0;
padding: 0;
width: auto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
&__inner {
display: inline-flex;
flex-direction: column;
align-items: flex-start;

margin: 0;
padding: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
loadScss,
attachToBody, // in order to use document.activeElement properly
} from '../../../core/jest/jestSetup'
import { render } from '@testing-library/react'
import Component from '../Dropdown'
import {
mockImplementationForDirectionObserver,
Expand Down Expand Up @@ -200,6 +201,29 @@ describe('Dropdown component', () => {
).toBe('true')
})

it('shows form-status with correct classes', () => {
render(
<Component
skip_portal
no_animation
data={mockData}
status="status text"
status_state="warn"
status_props={{ stretch: true }}
/>
)

expect(
Array.from(document.querySelector('.dnb-form-status').classList)
).toEqual([
'dnb-form-status',
'dnb-form-status--warn',
'dnb-form-status__size--default',
'dnb-form-status--stretch',
'dnb-form-status--has-content',
])
})

it('will stay open when keep_open and a selection is made', () => {
const on_change = jest.fn()
const Comp = mount(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2142,7 +2142,6 @@ legend.dnb-form-label {
.dnb-dropdown__inner {
display: inline-flex;
flex-direction: column;
align-items: flex-start;
margin: 0;
padding: 0;
width: auto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
&__inner {
display: inline-flex;
flex-direction: column;
align-items: flex-start;

margin: 0;
padding: 0;
Expand Down
22 changes: 22 additions & 0 deletions packages/dnb-eufemia/src/components/input/__tests__/Input.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
axeComponent,
loadScss,
} from '../../../core/jest/jestSetup'
import { render } from '@testing-library/react'
import Component from '../Input'
import { format } from '../../number-format/NumberUtils'

Expand Down Expand Up @@ -329,6 +330,27 @@ describe('Input component', () => {
expect(Comp.find('.dnb-form-status__text').text()).toBe('status')
})

it('shows form-status with correct classes', () => {
render(
<Component
value="value"
status="status text"
status_state="warn"
status_props={{ stretch: true }}
/>
)

expect(
Array.from(document.querySelector('.dnb-form-status').classList)
).toEqual([
'dnb-form-status',
'dnb-form-status--warn',
'dnb-form-status__size--default',
'dnb-form-status--stretch',
'dnb-form-status--has-content',
])
})

it('has a disabled attribute, once we set disabled to true', () => {
const Comp = mount(<Component />)
Comp.setProps({
Expand Down

0 comments on commit a961feb

Please sign in to comment.