Skip to content

Commit 7587254

Browse files
committed
updates
1 parent 0f4e45d commit 7587254

File tree

7 files changed

+66
-7
lines changed

7 files changed

+66
-7
lines changed

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test('Renders to match snapshot', () => {
1111

1212
test(`Renders default class ${styles.descriptionList}`, () => {
1313
render(<DescriptionList aria-label="list" />);
14-
expect(screen.getByLabelText('list')).toHaveClass(styles.descriptionList);
14+
expect(screen.getByLabelText('list')).toHaveClass(styles.descriptionList, { exact: true });
1515
});
1616

1717
test('Renders custom className', () => {
@@ -108,3 +108,35 @@ test(`Renders ${styles.modifiers.display_2xl} when displaySize = 2xl`, () => {
108108
render(<DescriptionList aria-label="list" displaySize="2xl" />);
109109
expect(screen.getByLabelText('list')).toHaveClass(styles.modifiers.display_2xl);
110110
});
111+
112+
test(`Renders style when isHorizontal and horizontalTermWidthModifier is set`, () => {
113+
render(
114+
<DescriptionList
115+
aria-label="list"
116+
isHorizontal
117+
horizontalTermWidthModifier={{
118+
default: '12ch',
119+
sm: '15ch',
120+
md: '20ch',
121+
lg: '28ch',
122+
xl: '30ch',
123+
'2xl': '35ch'
124+
}}
125+
/>
126+
);
127+
expect(screen.getByLabelText('list')).toHaveStyle({
128+
'--pf-v5-c-description-list--m-horizontal__term--width': '12ch',
129+
'--pf-v5-c-description-list--m-horizontal__term--width-on-sm': '15ch',
130+
'--pf-v5-c-description-list--m-horizontal__term--width-on-md': '20ch',
131+
'--pf-v5-c-description-list--m-horizontal__term--width-on-lg': '28ch',
132+
'--pf-v5-c-description-list--m-horizontal__term--width-on-xl': '30ch',
133+
'--pf-v5-c-description-list--m-horizontal__term--width-on-2xl': '35ch'
134+
});
135+
});
136+
137+
test(`Renders style when termWidth is set`, () => {
138+
render(<DescriptionList aria-label="list" isHorizontal termWidth="30px" />);
139+
expect(screen.getByLabelText('list')).toHaveStyle({
140+
'--pf-v5-c-description-list__term--width': '30px'
141+
});
142+
});

packages/react-core/src/components/DescriptionList/__tests__/DescriptionListDescription.test.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@ test('Renders to match snapshot', () => {
1111

1212
test(`Renders default class ${styles.descriptionListDescription}`, () => {
1313
render(<DescriptionListDescription>test</DescriptionListDescription>);
14-
expect(screen.getByText('test').parentElement).toHaveClass(styles.descriptionListDescription);
14+
expect(screen.getByText('test').parentElement).toHaveClass(styles.descriptionListDescription, { exact: true });
1515
});
1616

1717
test('Renders custom className', () => {
1818
render(<DescriptionListDescription className="custom">test</DescriptionListDescription>);
1919
expect(screen.getByText('test').parentElement).toHaveClass('custom');
2020
});
21+
22+
test('Renders spread props', () => {
23+
render(<DescriptionListDescription id="id">test</DescriptionListDescription>);
24+
expect(screen.getByText('test').parentElement).toHaveAttribute('id', 'id');
25+
});

packages/react-core/src/components/DescriptionList/__tests__/DescriptionListGroup.test.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@ test('Renders to match snapshot', () => {
1111

1212
test(`Renders default class ${styles.descriptionListGroup}`, () => {
1313
render(<DescriptionListGroup>test</DescriptionListGroup>);
14-
expect(screen.getByText('test')).toHaveClass(styles.descriptionListGroup);
14+
expect(screen.getByText('test')).toHaveClass(styles.descriptionListGroup, { exact: true });
1515
});
1616

1717
test('Renders custom className', () => {
1818
render(<DescriptionListGroup className="custom">test</DescriptionListGroup>);
1919
expect(screen.getByText('test')).toHaveClass('custom');
2020
});
21+
22+
test('Renders spread props', () => {
23+
render(<DescriptionListGroup id="id">test</DescriptionListGroup>);
24+
expect(screen.getByText('test')).toHaveAttribute('id', 'id');
25+
});

packages/react-core/src/components/DescriptionList/__tests__/DescriptionListHelpTextButton.test.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,17 @@ test('Renders to match snapshot', () => {
1111

1212
test(`Renders default class ${styles.descriptionListText}`, () => {
1313
render(<DescriptionListTermHelpTextButton>test</DescriptionListTermHelpTextButton>);
14-
expect(screen.getByText('test')).toHaveClass(styles.descriptionListText);
14+
expect(screen.getByText('test')).toHaveClass(`${styles.descriptionListText} ${styles.modifiers.helpText}`, {
15+
exact: true
16+
});
1517
});
1618

1719
test('Renders custom className', () => {
1820
render(<DescriptionListTermHelpTextButton className="custom">test</DescriptionListTermHelpTextButton>);
1921
expect(screen.getByText('test')).toHaveClass('custom');
2022
});
23+
24+
test('Renders spread props', () => {
25+
render(<DescriptionListTermHelpTextButton id="id">test</DescriptionListTermHelpTextButton>);
26+
expect(screen.getByText('test')).toHaveAttribute('id', 'id');
27+
});

packages/react-core/src/components/DescriptionList/__tests__/DescriptionListTerm.test.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ test('Renders to match snapshot', () => {
1111

1212
test(`Renders default class ${styles.descriptionListTerm}`, () => {
1313
render(<DescriptionListTerm>test</DescriptionListTerm>);
14-
expect(screen.getByText('test').parentElement).toHaveClass(styles.descriptionListTerm);
14+
expect(screen.getByText('test').parentElement).toHaveClass(styles.descriptionListTerm, { exact: true });
1515
});
1616

1717
test(`Renders default class ${styles.descriptionListText}`, () => {
1818
render(<DescriptionListTerm>test</DescriptionListTerm>);
19-
expect(screen.getByText('test')).toHaveClass(styles.descriptionListText);
19+
expect(screen.getByText('test')).toHaveClass(styles.descriptionListText, { exact: true });
2020
});
2121

2222
test('Renders custom className', () => {
@@ -28,3 +28,8 @@ test('Renders icon', () => {
2828
render(<DescriptionListTerm icon={<div>icon</div>}>test</DescriptionListTerm>);
2929
expect(screen.getByText('icon').parentElement).toHaveClass(styles.descriptionListTermIcon);
3030
});
31+
32+
test('Renders spread props', () => {
33+
render(<DescriptionListTerm id="id">test</DescriptionListTerm>);
34+
expect(screen.getByText('test').parentElement).toHaveAttribute('id', 'id');
35+
});

packages/react-core/src/components/DescriptionList/__tests__/DescriptionListHelpText.test.tsx renamed to packages/react-core/src/components/DescriptionList/__tests__/DescriptionListTermHelpText.test.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@ test('Renders to match snapshot', () => {
1111

1212
test(`Renders default class ${styles.descriptionListTerm}`, () => {
1313
render(<DescriptionListTermHelpText>test</DescriptionListTermHelpText>);
14-
expect(screen.getByText('test')).toHaveClass(styles.descriptionListTerm);
14+
expect(screen.getByText('test')).toHaveClass(styles.descriptionListTerm, { exact: true });
1515
});
1616

1717
test('Renders custom className', () => {
1818
render(<DescriptionListTermHelpText className="custom">test</DescriptionListTermHelpText>);
1919
expect(screen.getByText('test')).toHaveClass('custom');
2020
});
21+
22+
test('Renders spread props', () => {
23+
render(<DescriptionListTermHelpText id="id">test</DescriptionListTermHelpText>);
24+
expect(screen.getByText('test')).toHaveAttribute('id', 'id');
25+
});

0 commit comments

Comments
 (0)