Skip to content

Commit 957bcc0

Browse files
pawelgrimmclaude
andcommitted
test: add FieldChromeContainer border-radius and class assertions
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7b9c4e2 commit 957bcc0

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

src/control-presentation/field-chrome-container.test.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ import { axe } from 'jest-axe'
77
import { FieldChromeContainer } from './field-chrome-container'
88

99
describe('FieldChromeContainer', () => {
10+
// Note: CSS `:has()`-driven state styling (readonly/disabled tinting, error
11+
// border via aria-invalid, hover/focus border colors) is verified by visual
12+
// regression / Chromatic, not Jest. jsdom does not implement `:has()` for
13+
// computed styles, so asserting these rules in Jest would require parsing
14+
// the CSS module and computing match — out of scope.
15+
1016
it('renders children', () => {
1117
render(
1218
<FieldChromeContainer>
@@ -35,6 +41,41 @@ describe('FieldChromeContainer', () => {
3541
expect(container.firstElementChild).toHaveClass('custom')
3642
})
3743

44+
describe('chrome class wiring', () => {
45+
it('applies the base container class to the wrapper', () => {
46+
const { container } = render(
47+
<FieldChromeContainer>
48+
<input aria-label="control" />
49+
</FieldChromeContainer>,
50+
)
51+
// The class is hashed by CSS Modules in production but the import yields
52+
// an object whose `.container` value is the actual className used.
53+
// We assert presence of the class indirectly via toHaveClass with the
54+
// module's resolved class name.
55+
expect(container.firstElementChild?.className).toMatch(/container/)
56+
})
57+
58+
it('applies the small border-radius class by default', () => {
59+
const { container } = render(
60+
<FieldChromeContainer>
61+
<input aria-label="control" />
62+
</FieldChromeContainer>,
63+
)
64+
expect(container.firstElementChild?.className).toMatch(/borderRadiusSmall/)
65+
expect(container.firstElementChild?.className).not.toMatch(/borderRadiusLarge/)
66+
})
67+
68+
it('applies the large border-radius class when borderRadius="large"', () => {
69+
const { container } = render(
70+
<FieldChromeContainer borderRadius="large">
71+
<input aria-label="control" />
72+
</FieldChromeContainer>,
73+
)
74+
expect(container.firstElementChild?.className).toMatch(/borderRadiusLarge/)
75+
expect(container.firstElementChild?.className).not.toMatch(/borderRadiusSmall/)
76+
})
77+
})
78+
3879
describe('click-to-focus dispatch', () => {
3980
it('focuses the inner control when the wrapper is clicked', () => {
4081
const { container } = render(

0 commit comments

Comments
 (0)