Skip to content

Commit b7ab4f3

Browse files
committed
test rowWrap for all breakpoints
1 parent 0fd02ce commit b7ab4f3

File tree

3 files changed

+80
-53
lines changed

3 files changed

+80
-53
lines changed

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

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -148,27 +148,32 @@ describe('Toolbar', () => {
148148
expect(screen.getByTestId('Toolbar-test-secondary-id')).toHaveClass(styles.modifiers.secondary);
149149
});
150150

151-
it('should render ToolbarContent with pf-m-wrap when rowWrap is set to wrap', () => {
152-
render(
153-
<Toolbar>
154-
<ToolbarContent data-testid="toolbarcontent" rowWrap={{ default: 'wrap' }}>
155-
Test
156-
</ToolbarContent>
157-
</Toolbar>
158-
);
159-
160-
expect(screen.getByTestId('toolbarcontent').querySelector('div')).toHaveClass('pf-m-wrap');
161-
});
162-
163-
it('should render ToolbarContent with pf-m-nowrap when rowWrap is set to nowrap', () => {
164-
render(
165-
<Toolbar>
166-
<ToolbarContent data-testid="toolbarcontent" rowWrap={{ default: 'nowrap' }}>
167-
Test
168-
</ToolbarContent>
169-
</Toolbar>
170-
);
171-
172-
expect(screen.getByTestId('toolbarcontent').querySelector('div')).toHaveClass('pf-m-nowrap');
151+
describe('ToobarContent rowWrap', () => {
152+
const bps = ['default', 'sm', 'md', 'lg', 'xl', '2xl'];
153+
154+
describe.each(bps)(`rowWrap at various breakpoints`, (bp) => {
155+
it(`should render with pf-m-wrap when rowWrap is set to wrap at ${bp}`, () => {
156+
render(
157+
<Toolbar>
158+
<ToolbarContent data-testid="toolbarconent" rowWrap={{ [bp]: 'wrap' }}>
159+
Test
160+
</ToolbarContent>
161+
</Toolbar>
162+
);
163+
const bpWrapClass = bp === 'default' ? 'pf-m-wrap' : `pf-m-wrap-on-${bp}`;
164+
165+
expect(screen.getByTestId('toolbarconent').querySelector('div')).toHaveClass(bpWrapClass);
166+
});
167+
168+
it(`should render with pf-m-nowrap when rowWrap is set to nowrap at ${bp}`, () => {
169+
render(
170+
<ToolbarContent data-testid="toolbarconent" rowWrap={{ [bp]: 'nowrap' }}>
171+
Test
172+
</ToolbarContent>
173+
);
174+
const bpNoWrapClass = bp === 'default' ? 'pf-m-nowrap' : `pf-m-nowrap-on-${bp}`;
175+
expect(screen.getByTestId('toolbarconent').querySelector('div')).toHaveClass(bpNoWrapClass);
176+
});
177+
});
173178
});
174179
});
Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { render, screen } from '@testing-library/react';
22
import { ToolbarGroup } from '../ToolbarGroup';
33

4-
describe('ToolbarItem', () => {
4+
describe('ToolbarGroup', () => {
55
it('should render with pf-m-overflow-container when isOverflowContainer is set', () => {
66
render(
77
<ToolbarGroup data-testid="toolbargroup" isOverflowContainer>
@@ -10,20 +10,31 @@ describe('ToolbarItem', () => {
1010
);
1111
expect(screen.getByTestId('toolbargroup')).toHaveClass('pf-m-overflow-container');
1212
});
13-
it('should render with pf-m-wrap when rowWrap is set to wrap', () => {
14-
render(
15-
<ToolbarGroup data-testid="toolbargroup" rowWrap={{ default: 'wrap' }}>
16-
Test
17-
</ToolbarGroup>
18-
);
19-
expect(screen.getByTestId('toolbargroup')).toHaveClass('pf-m-wrap');
20-
});
21-
it('should render with pf-m-nowrap when rowWrap is set to nowrap', () => {
22-
render(
23-
<ToolbarGroup data-testid="toolbargroup" rowWrap={{ default: 'nowrap' }}>
24-
Test
25-
</ToolbarGroup>
26-
);
27-
expect(screen.getByTestId('toolbargroup')).toHaveClass('pf-m-nowrap');
13+
14+
describe('ToobarGroup rowWrap', () => {
15+
const bps = ['default', 'sm', 'md', 'lg', 'xl', '2xl'];
16+
17+
describe.each(bps)(`rowWrap at various breakpoints`, (bp) => {
18+
it(`should render with pf-m-wrap when rowWrap is set to wrap at ${bp}`, () => {
19+
render(
20+
<ToolbarGroup data-testid="toolbargroup" rowWrap={{ [bp]: 'wrap' }}>
21+
Test
22+
</ToolbarGroup>
23+
);
24+
const bpWrapClass = bp === 'default' ? 'pf-m-wrap' : `pf-m-wrap-on-${bp}`;
25+
26+
expect(screen.getByTestId('toolbargroup')).toHaveClass(bpWrapClass);
27+
});
28+
29+
it(`should render with pf-m-nowrap when rowWrap is set to nowrap at ${bp}`, () => {
30+
render(
31+
<ToolbarGroup data-testid="toolbargroup" rowWrap={{ [bp]: 'nowrap' }}>
32+
Test
33+
</ToolbarGroup>
34+
);
35+
const bpNoWrapClass = bp === 'default' ? 'pf-m-nowrap' : `pf-m-nowrap-on-${bp}`;
36+
expect(screen.getByTestId('toolbargroup')).toHaveClass(bpNoWrapClass);
37+
});
38+
});
2839
});
2940
});

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

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,31 @@ describe('ToolbarItem', () => {
1010
);
1111
expect(screen.getByTestId('toolbaritem')).toHaveClass('pf-m-overflow-container');
1212
});
13-
it('should render with pf-m-wrap when rowWrap is set to wrap', () => {
14-
render(
15-
<ToolbarItem data-testid="toolbaritem" rowWrap={{ default: 'wrap' }}>
16-
Test
17-
</ToolbarItem>
18-
);
19-
expect(screen.getByTestId('toolbaritem')).toHaveClass('pf-m-wrap');
20-
});
21-
it('should render with pf-m-nowrap when rowWrap is set to nowrap', () => {
22-
render(
23-
<ToolbarItem data-testid="toolbaritem" rowWrap={{ default: 'nowrap' }}>
24-
Test
25-
</ToolbarItem>
26-
);
27-
expect(screen.getByTestId('toolbaritem')).toHaveClass('pf-m-nowrap');
13+
14+
describe('ToobarItem rowWrap', () => {
15+
const bps = ['default', 'sm', 'md', 'lg', 'xl', '2xl'];
16+
17+
describe.each(bps)(`rowWrap at various breakpoints`, (bp) => {
18+
it(`should render with pf-m-wrap when rowWrap is set to wrap at ${bp}`, () => {
19+
render(
20+
<ToolbarItem data-testid="toolbaritem" rowWrap={{ [bp]: 'wrap' }}>
21+
Test
22+
</ToolbarItem>
23+
);
24+
const bpWrapClass = bp === 'default' ? 'pf-m-wrap' : `pf-m-wrap-on-${bp}`;
25+
26+
expect(screen.getByTestId('toolbaritem')).toHaveClass(bpWrapClass);
27+
});
28+
29+
it(`should render with pf-m-nowrap when rowWrap is set to nowrap at ${bp}`, () => {
30+
render(
31+
<ToolbarItem data-testid="toolbaritem" rowWrap={{ [bp]: 'nowrap' }}>
32+
Test
33+
</ToolbarItem>
34+
);
35+
const bpNoWrapClass = bp === 'default' ? 'pf-m-nowrap' : `pf-m-nowrap-on-${bp}`;
36+
expect(screen.getByTestId('toolbaritem')).toHaveClass(bpNoWrapClass);
37+
});
38+
});
2839
});
2940
});

0 commit comments

Comments
 (0)