Skip to content

Commit f27e3d9

Browse files
committed
fix(ToolbarItem): update widths tests to use CSS values and remove type cast
1 parent 93919cd commit f27e3d9

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

packages/react-core/src/components/Toolbar/__tests__/ToolbarItem.test.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ describe('ToolbarItem', () => {
2323
</ToolbarItem>
2424
);
2525
const bpWrapClass = bp === 'default' ? 'pf-m-wrap' : `pf-m-wrap-on-${bp}`;
26-
2726
expect(screen.getByTestId('toolbaritem')).toHaveClass(bpWrapClass);
2827
});
2928

@@ -41,17 +40,17 @@ describe('ToolbarItem', () => {
4140

4241
describe('ToolbarItem widths', () => {
4342
const bps = ['default', 'sm', 'md', 'lg', 'xl', '2xl'];
44-
const sizes = ['sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl'];
43+
const widths = ['100px', '3rem', '50%', '200px'];
4544

4645
describe.each(bps)('widths at various breakpoints', (bp) => {
47-
it.each(sizes)(`applies width CSS var when widths is set to %s at ${bp}`, (size) => {
46+
it.each(widths)(`applies width CSS var when widths is set to %s at ${bp}`, (width) => {
4847
render(
49-
<ToolbarItem data-testid="toolbaritem" widths={{ [bp]: size }}>
48+
<ToolbarItem data-testid="toolbaritem" widths={{ [bp]: width }}>
5049
Test
5150
</ToolbarItem>
5251
);
5352
const styleAttr = screen.getByTestId('toolbaritem').getAttribute('style') || '';
54-
const cssVarName = `${(toolbarItemWidth as any).name}${bp === 'default' ? '' : `-on-${bp}`}`;
53+
const cssVarName = `${toolbarItemWidth.name}${bp === 'default' ? '' : `-on-${bp}`}`;
5554
expect(styleAttr).toContain(cssVarName);
5655
});
5756
});

0 commit comments

Comments
 (0)