Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(ai-label/pagination-skeleton): increase coverage #17748

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
*/

import React from 'react';
import { AILabel } from '../';
import { AILabel, AILabelContent, AILabelActions } from '../';
import { Button } from '../../Button';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

const prefix = 'cds';

Expand Down Expand Up @@ -114,4 +116,45 @@ describe('AILabel', () => {
);
});
});

it('should handle revert click', async () => {
render(
<AILabel
revertActive
revertLabel="Test revert label"
onRevertClick={() => {}}
/>
);

await userEvent.click(screen.getByRole('button'));
});
});

describe('AILabelContent', () => {
it('should render with content', () => {
render(
<AILabel>
<AILabelContent>Children test</AILabelContent>
</AILabel>
);

expect(screen.getByText('Children test')).toBeInTheDocument();
});
});

describe('AILabelActions', () => {
it('should render with actions', () => {
render(
<AILabel>
<AILabelContent>
Children test
<AILabelActions>
<Button>View details</Button>
</AILabelActions>
</AILabelContent>
</AILabel>
);

expect(screen.getByText('View details')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import Pagination from './Pagination';
import Pagination from '../Pagination';
import userEvent from '@testing-library/user-event';
import { getAllByRole, render, screen } from '@testing-library/react';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright IBM Corp. 2016, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';
import { PaginationSkeleton } from '../Pagination.Skeleton';
import { render } from '@testing-library/react';

describe('PaginationSkeleton', () => {
it('should support a custom `className` prop on the outermost element', () => {
const { container } = render(
<PaginationSkeleton aria-label="test" className="test" />
);
expect(container.firstChild).toHaveClass('test');
});

it('should spread additional props on the outermost element', () => {
const { container } = render(
<PaginationSkeleton aria-label="test" data-testid="test" />
);
expect(container.firstChild).toHaveAttribute('data-testid', 'test');
});
});
Loading