Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thatblindgeye committed May 10, 2023
1 parent 1f4635d commit da7cc60
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
18 changes: 11 additions & 7 deletions packages/react-core/src/components/Card/__tests__/Card.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Card', () => {
test('allows passing in a React Component as the component', () => {
const Component = () => <div>im a div</div>;

render(<Card component={(Component as unknown) as keyof JSX.IntrinsicElements} />);
render(<Card component={Component as unknown as keyof JSX.IntrinsicElements} />);
expect(screen.getByText('im a div')).toBeInTheDocument();
});

Expand All @@ -47,16 +47,18 @@ describe('Card', () => {

const card = screen.getByText('selectable card');
expect(card).toHaveClass('pf-m-selectable');
expect(card).toHaveAttribute('tabindex', '0');
});

test('card with isSelectable and isSelected applied ', () => {
render(<Card isSelectable isSelected>selected and selectable card</Card>);
render(
<Card isSelectable isSelected>
selected and selectable card
</Card>
);

const card = screen.getByText('selected and selectable card');
expect(card).toHaveClass('pf-m-selectable');
expect(card).toHaveClass('pf-m-selected');
expect(card).toHaveAttribute('tabindex', '0');
});

test('card with only isSelected applied - not change', () => {
Expand All @@ -81,7 +83,11 @@ describe('Card', () => {
});

test('card with isSelectableRaised and isSelected applied ', () => {
render(<Card isSelected isSelectableRaised>raised selected card</Card>);
render(
<Card isSelected isSelectableRaised>
raised selected card
</Card>
);

const card = screen.getByText('raised selected card');
expect(card).toHaveClass('pf-m-selectable-raised');
Expand Down Expand Up @@ -154,7 +160,6 @@ describe('Card', () => {
});

test('card applies the supplied card title as the aria label of the hidden input', () => {

// this component is used to mock the CardTitle's title registry behavior to keep this a pure unit test
const MockCardTitle = ({ children }) => {
const { registerTitleId } = React.useContext(CardContext);
Expand All @@ -179,7 +184,6 @@ describe('Card', () => {
});

test('card prioritizes selectableInputAriaLabel over card title labelling via card title', () => {

// this component is used to mock the CardTitle's title registry behavior to keep this a pure unit test
const MockCardTitle = ({ children }) => {
const { registerTitleId } = React.useContext(CardContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ exports[`CardHeader actions are rendered 1`] = `
>
<div
class="pf-v5-c-card__actions"
>
</div>
/>
</div>
</DocumentFragment>
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,19 @@ exports[`ToggleGroup should render non-ToggleGroupItem children 1`] = `
<DocumentFragment>
<div
aria-label="non-element children"
class="pf-c-toggle-group pf-m-compact"
class="pf-v5-c-toggle-group pf-m-compact"
role="group"
>
<div
class="pf-c-toggle-group__item"
class="pf-v5-c-toggle-group__item"
>
<button
aria-pressed="false"
class="pf-c-toggle-group__button"
class="pf-v5-c-toggle-group__button"
type="button"
>
<span
class="pf-c-toggle-group__text"
class="pf-v5-c-toggle-group__text"
>
Test
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class CardDemo extends React.Component {
<CardFooter>Footer</CardFooter>
</Card>
<br></br>
<Card isSelectable isSelected>
<Card isSelectable isSelected tabIndex={0}>
<CardTitle>Header</CardTitle>
<CardBody>Body</CardBody>
<CardFooter>Footer</CardFooter>
Expand Down Expand Up @@ -171,6 +171,7 @@ export class CardDemo extends React.Component {
id="selectableCard"
isSelectable
isSelected={this.state.selected === 'selectableCard'}
tabIndex={0}
onKeyDown={this.onKeyDown}
>
<CardTitle>Header</CardTitle>
Expand Down

0 comments on commit da7cc60

Please sign in to comment.