@@ -7,6 +7,12 @@ import { axe } from 'jest-axe'
77import { FieldChromeContainer } from './field-chrome-container'
88
99describe ( '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 ( / c o n t a i n e r / )
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 ( / b o r d e r R a d i u s S m a l l / )
65+ expect ( container . firstElementChild ?. className ) . not . toMatch ( / b o r d e r R a d i u s L a r g e / )
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 ( / b o r d e r R a d i u s L a r g e / )
75+ expect ( container . firstElementChild ?. className ) . not . toMatch ( / b o r d e r R a d i u s S m a l l / )
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