Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/Headings/heading.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ describe('<Heading />', () => {

expect(wrapper).toBeInTheDocument();
expect(wrapper.tagName.toLowerCase()).toBe('header');
expect(wrapper.classList.contains('m-slug-header'));
expect(wrapper.classList.contains('m-slug-header')).toBeTruthy();

const content = screen.getByText(text);
expect(content.tagName.toLowerCase()).toBe('h2');
expect(content.classList.contains('a-heading'));
expect(content.classList.contains('m-slug-header__heading')).toBeTruthy();
});
});
1 change: 1 addition & 0 deletions src/components/Headings/heading.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@cfpb/cfpb-design-system/src/components/cfpb-typography/slug-header.scss';
import classnames from 'classnames';
import { JSX } from 'react';
import type { HTMLProps } from 'react';
Expand Down
14 changes: 14 additions & 0 deletions src/components/Headings/headings.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,18 @@ export const Slug: Story = {
type: 'slug',
children: 'Slug',
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const slugHeading = canvas.getByRole('heading', {
level: 2,
name: /slug/i,
});

await expect(slugHeading.classList.contains('m-slug-header__heading')).toBe(
true,
);
await expect(
slugHeading.closest('header')?.classList.contains('m-slug-header'),
).toBe(true);
},
};
Loading