Skip to content

Commit

Permalink
chore: add additional construct tests for the as prop
Browse files Browse the repository at this point in the history
  • Loading branch information
eels committed Oct 28, 2021
1 parent 17c3554 commit 40b74ae
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/lib/construct.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,36 @@ describe('lib/construct', () => {
expect(screen.getByRole('heading')).toHaveClass('heading extended');
});

it('should render a basic extended component via the `as` prop', () => {
const parameters: ConstructOptions = {
attrs: {},
classNames: 'heading',
styles: styles,
target: 'div',
};

render(createElement(construct(parameters), { as: 'h1' }));
expect(screen.getByRole('heading')).toBeInTheDocument();
expect(screen.getByRole('heading')).toHaveClass('heading');
});

it('should render a custom extended component via the `as` prop', () => {
const parameters: ConstructOptions = {
attrs: {},
classNames: 'heading',
styles: styles,
target: 'div',
};

const CustomComponent = ({ className }: { className: string }) => {
return createElement('h1', { className });
};

render(createElement(construct(parameters), { as: CustomComponent }));
expect(screen.getByRole('heading')).toBeInTheDocument();
expect(screen.getByRole('heading')).toHaveClass('heading');
});

it('should render a basic component without passing non-valid props as attributes', () => {
const parameters: ConstructOptions = {
attrs: {},
Expand Down

0 comments on commit 40b74ae

Please sign in to comment.