You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/app/react/components/DashboardItem/DashboardItem.test.tsx

30 lines
927 B

import { render } from '@/react-tools/test-utils';
import { DashboardItem } from './DashboardItem';
test('should show provided resource value', async () => {
const { getByLabelText } = renderComponent(1);
const value = getByLabelText('value');
expect(value).toBeVisible();
expect(value).toHaveTextContent('1');
});
test('should show provided resource type', async () => {
const { getByLabelText } = renderComponent(0, '', 'Test');
const title = getByLabelText('resourceType');
expect(title).toBeVisible();
expect(title).toHaveTextContent('Test');
});
test('should have accessibility label created from the provided resource type', async () => {
const { getByLabelText } = renderComponent(0, '', 'testLabel');
expect(getByLabelText('testLabel')).toBeTruthy();
});
function renderComponent(value = 0, icon = '', type = '') {
return render(<DashboardItem value={value} icon={icon} type={type} />);
}