aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/src/components/FeedList.test.tsx
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-13 07:46:58 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-13 09:38:38 -0800
commit23a48e1d498680be769e931f46ddb1fd44f38d1a (patch)
tree54bb607e19b3eec0e5c932e6748d9ca6304d4b17 /frontend/src/components/FeedList.test.tsx
parenta5cd9538b0db731a0d0e10e58804ef8ad32211b7 (diff)
downloadneko-23a48e1d498680be769e931f46ddb1fd44f38d1a.tar.gz
neko-23a48e1d498680be769e931f46ddb1fd44f38d1a.tar.bz2
neko-23a48e1d498680be769e931f46ddb1fd44f38d1a.zip
Implement Tag View and fix tests
Diffstat (limited to 'frontend/src/components/FeedList.test.tsx')
-rw-r--r--frontend/src/components/FeedList.test.tsx39
1 files changed, 31 insertions, 8 deletions
diff --git a/frontend/src/components/FeedList.test.tsx b/frontend/src/components/FeedList.test.tsx
index 92ff345..eba9b88 100644
--- a/frontend/src/components/FeedList.test.tsx
+++ b/frontend/src/components/FeedList.test.tsx
@@ -28,9 +28,20 @@ describe('FeedList Component', () => {
{ _id: 2, title: 'Feed Two', url: 'http://test.com/rss', web_url: 'http://test.com', category: 'News' },
];
- (global.fetch as any).mockResolvedValueOnce({
- ok: true,
- json: async () => mockFeeds,
+ (global.fetch as any).mockImplementation((url: string) => {
+ if (url.includes('/api/feed/')) {
+ return Promise.resolve({
+ ok: true,
+ json: async () => mockFeeds,
+ });
+ }
+ if (url.includes('/api/tag')) {
+ return Promise.resolve({
+ ok: true,
+ json: async () => [{ title: 'Tech' }],
+ });
+ }
+ return Promise.reject(new Error(`Unknown URL: ${url}`));
});
render(
@@ -42,12 +53,13 @@ describe('FeedList Component', () => {
await waitFor(() => {
expect(screen.getByText('Feed One')).toBeInTheDocument();
expect(screen.getByText('Feed Two')).toBeInTheDocument();
- expect(screen.getByText('Tech')).toBeInTheDocument();
+ const techElements = screen.getAllByText('Tech');
+ expect(techElements.length).toBeGreaterThan(0);
});
});
it('handles fetch error', async () => {
- (global.fetch as any).mockRejectedValueOnce(new Error('API Error'));
+ (global.fetch as any).mockImplementation(() => Promise.reject(new Error('API Error')));
render(
<BrowserRouter>
@@ -61,9 +73,20 @@ describe('FeedList Component', () => {
});
it('handles empty feed list', async () => {
- (global.fetch as any).mockResolvedValueOnce({
- ok: true,
- json: async () => [],
+ (global.fetch as any).mockImplementation((url: string) => {
+ if (url.includes('/api/feed/')) {
+ return Promise.resolve({
+ ok: true,
+ json: async () => [],
+ });
+ }
+ if (url.includes('/api/tag')) {
+ return Promise.resolve({
+ ok: true,
+ json: async () => [],
+ });
+ }
+ return Promise.reject(new Error(`Unknown URL: ${url}`));
});
render(