2022-11-28 02:00:28 +00:00
|
|
|
import { User } from 'lucide-react';
|
|
|
|
|
2022-02-24 23:22:56 +00:00
|
|
|
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 () => {
|
2022-11-28 02:00:28 +00:00
|
|
|
const { getByLabelText } = renderComponent(0, User, 'Test');
|
2022-02-24 23:22:56 +00:00
|
|
|
const title = getByLabelText('resourceType');
|
|
|
|
|
|
|
|
expect(title).toBeVisible();
|
|
|
|
expect(title).toHaveTextContent('Test');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should have accessibility label created from the provided resource type', async () => {
|
2022-11-28 02:00:28 +00:00
|
|
|
const { getByLabelText } = renderComponent(0, User, 'testLabel');
|
2022-02-24 23:22:56 +00:00
|
|
|
|
|
|
|
expect(getByLabelText('testLabel')).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
2022-11-28 02:00:28 +00:00
|
|
|
function renderComponent(value = 0, icon = User, type = '') {
|
2022-02-24 23:22:56 +00:00
|
|
|
return render(<DashboardItem value={value} icon={icon} type={type} />);
|
|
|
|
}
|