This commit is contained in:
@@ -53,18 +53,22 @@ const album: AlbumRef = {
|
|||||||
afterEach(() => vi.clearAllMocks());
|
afterEach(() => vi.clearAllMocks());
|
||||||
|
|
||||||
describe('AlbumCard', () => {
|
describe('AlbumCard', () => {
|
||||||
test('renders cover, title, year inside a link to /albums/:id', () => {
|
test('renders cover, title, artist inside a link to /albums/:id', () => {
|
||||||
const { container } = render(AlbumCard, { props: { album } });
|
const { container } = render(AlbumCard, { props: { album } });
|
||||||
const link = screen.getByRole('link');
|
const link = screen.getByRole('link');
|
||||||
expect(link).toHaveAttribute('href', '/albums/xyz');
|
expect(link).toHaveAttribute('href', '/albums/xyz');
|
||||||
expect(link).toHaveTextContent('Kind of Blue');
|
expect(link).toHaveTextContent('Kind of Blue');
|
||||||
expect(link).toHaveTextContent('1959');
|
expect(link).toHaveTextContent('Miles Davis');
|
||||||
|
// The year is intentionally omitted from the Home tile —
|
||||||
|
// dropped in the visual polish pass; the album detail page
|
||||||
|
// still shows it.
|
||||||
|
expect(link).not.toHaveTextContent('1959');
|
||||||
|
|
||||||
const img = container.querySelector('img') as HTMLImageElement;
|
const img = container.querySelector('img') as HTMLImageElement;
|
||||||
expect(img.src).toContain('/api/albums/xyz/cover');
|
expect(img.src).toContain('/api/albums/xyz/cover');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('year is omitted when not present', () => {
|
test('year is not rendered on the tile even when present', () => {
|
||||||
render(AlbumCard, { props: { album: { ...album, year: undefined } } });
|
render(AlbumCard, { props: { album: { ...album, year: undefined } } });
|
||||||
expect(screen.queryByText(/1959/)).not.toBeInTheDocument();
|
expect(screen.queryByText(/1959/)).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user