import { render, screen } from '@testing-library/react';
import React from 'react';
import { describe, expect, it } from 'vitest';
import ResourceListPage from './ResourceListPage';
vi.mock('@kinvolk/headlamp-plugin/lib/CommonComponents', () => ({
Loader: ({ title }: { title: string }) =>
{title}
,
SectionBox: ({ title, children }: { title: React.ReactNode; children?: React.ReactNode }) => (
),
SectionHeader: ({ title }: { title: string }) => {title}
,
NameValueTable: ({
rows,
}: {
rows: Array<{ name: React.ReactNode; value: React.ReactNode }>;
}) => (
{rows.map((r, i) => (
- {r.name}
- {r.value}
))}
),
StatusLabel: ({ status, children }: { status: string; children?: React.ReactNode }) => (
{children}
),
}));
describe('ResourceListPage', () => {
it('renders the "My Plugin" heading', () => {
render();
expect(screen.getByText('My Plugin')).toBeInTheDocument();
});
it('shows the example resource group row', () => {
render();
expect(screen.getByText('Resource Group')).toBeInTheDocument();
expect(screen.getByText('your.group.io/v1')).toBeInTheDocument();
});
it('shows the example Kind row', () => {
render();
expect(screen.getByText('Kind')).toBeInTheDocument();
expect(screen.getByText('YourCustomResource')).toBeInTheDocument();
});
});