Skip to content

Commit

Permalink
fix: remove FormRow context support from /elements (#2031)
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed May 31, 2023
1 parent a0aaffc commit 6560a80
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions packages/dnb-eufemia/src/elements/__tests__/Element.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '../../core/jest/jestSetup'
import { render } from '@testing-library/react'
import Element, { defaultProps } from '../Element'
import { Provider } from '../../shared'

const props = fakeProps(require.resolve('../Element'), {
optional: true,
Expand Down Expand Up @@ -52,6 +53,24 @@ describe('Element', () => {
'dnb-space__top--medium',
'dnb-p',
])

const attributes = Array.from(element.attributes).map(
(attr) => attr.name
)

expect(attributes).toEqual(['class'])
})

it('should render children', () => {
render(
<Element as="p" top="medium">
text
</Element>
)

const element = document.querySelector('.dnb-p')

expect(element.textContent).toBe('text')
})

it('have to support skeleton', () => {
Expand All @@ -76,6 +95,33 @@ describe('Element', () => {
)
})

it('have inherit skeleton prop from shared Provider', () => {
const { container } = render(
<Provider skeleton>
<Element as="p" className="my-p">
text
</Element>
</Provider>
)

const element = container.querySelector('.my-p')

expect(element.getAttribute('class')).toBe(
'my-p dnb-skeleton dnb-skeleton--font dnb-p'
)

const attributes = Array.from(element.attributes).map(
(attr) => attr.name
)

expect(attributes).toEqual([
'class',
'disabled', // because its a skeleton
'aria-disabled', // because its a skeleton
'aria-label', // because its a skeleton
])
})

it('does not have inner_ref null inside default props', () => {
expect(defaultProps['inner_ref']).toBe(undefined)
})
Expand Down

0 comments on commit 6560a80

Please sign in to comment.