From 3ba71500bc2d60a00ca81b9439305029670f4d52 Mon Sep 17 00:00:00 2001
From: Adam Mathes <adam@adammathes.com>
Date: Fri, 13 Feb 2026 06:55:21 -0800
Subject: Implement Frontend Feed Items View with tests

---
 frontend/src/components/FeedItems.test.tsx | 52 ++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 frontend/src/components/FeedItems.test.tsx

(limited to 'frontend/src/components/FeedItems.test.tsx')

diff --git a/frontend/src/components/FeedItems.test.tsx b/frontend/src/components/FeedItems.test.tsx
new file mode 100644
index 0000000..9c271c4
--- /dev/null
+++ b/frontend/src/components/FeedItems.test.tsx
@@ -0,0 +1,52 @@
+import React from 'react';
+import '@testing-library/jest-dom';
+import { render, screen, waitFor } from '@testing-library/react';
+import { MemoryRouter, Route, Routes } from 'react-router-dom';
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import FeedItems from './FeedItems';
+
+describe('FeedItems Component', () => {
+    beforeEach(() => {
+        vi.resetAllMocks();
+        global.fetch = vi.fn();
+    });
+
+    it('renders loading state', () => {
+        (global.fetch as any).mockImplementation(() => new Promise(() => { }));
+        render(
+            <MemoryRouter initialEntries={['/feed/1']}>
+                <Routes>
+                    <Route path="/feed/:feedId" element={<FeedItems />} />
+                </Routes>
+            </MemoryRouter>
+        );
+        expect(screen.getByText(/loading items/i)).toBeInTheDocument();
+    });
+
+    it('renders items for a feed', async () => {
+        const mockItems = [
+            { _id: 101, title: 'Item One', url: 'http://example.com/1', publish_date: '2023-01-01', read: false },
+            { _id: 102, title: 'Item Two', url: 'http://example.com/2', publish_date: '2023-01-02', read: true },
+        ];
+
+        (global.fetch as any).mockResolvedValueOnce({
+            ok: true,
+            json: async () => mockItems,
+        });
+
+        render(
+            <MemoryRouter initialEntries={['/feed/1']}>
+                <Routes>
+                    <Route path="/feed/:feedId" element={<FeedItems />} />
+                </Routes>
+            </MemoryRouter>
+        );
+
+        await waitFor(() => {
+            expect(screen.getByText('Item One')).toBeInTheDocument();
+            expect(screen.getByText('Item Two')).toBeInTheDocument();
+        });
+
+        expect(global.fetch).toHaveBeenCalledWith('/api/stream?feed_id=1');
+    });
+});
-- 
cgit v1.2.3

