1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import { describe, it, expect } from 'vitest';
import { createFeedItem } from './FeedItem';
import type { Item } from '../types';
describe('FeedItem Component', () => {
const mockItem: Item = {
_id: 1,
title: 'Item Title',
url: 'http://test',
publish_date: '2023-01-01',
read: false,
starred: false,
feed_title: 'Feed Title',
description: 'Desc'
} as any;
it('should render an item correctly', () => {
const html = createFeedItem(mockItem);
expect(html).toContain('Item Title');
expect(html).toContain('data-id="1"');
expect(html).toContain('unread');
});
it('should show read state', () => {
const html = createFeedItem({ ...mockItem, read: true });
expect(html).toContain('read');
expect(html).not.toContain('unread');
});
it('should show starred state', () => {
const html = createFeedItem({ ...mockItem, starred: true });
expect(html).toContain('is-starred');
});
it('should fallback to (No Title) if title is missing', () => {
const html = createFeedItem({ ...mockItem, title: '' });
expect(html).toContain('(No Title)');
});
});
|