fix(tests): mock global fetch and restore SDLineupManager useEffect guard

This commit is contained in:
mwhit 2026-05-17 06:17:19 +00:00
parent aa27fcc362
commit 60a61e78e3
2 changed files with 5 additions and 1 deletions

View file

@ -82,7 +82,7 @@ const SDLineupManager = ({ sourceId }) => {
}, [sourceId]);
useEffect(() => {
if (sourceId && sourceType === 'schedules_direct') {
if (sourceId) {
fetchActiveLineups();
// Fetch country list from SD API per their recommendation to not hardcode
fetch('https://json.schedulesdirect.org/20141201/available/countries')

View file

@ -2,6 +2,10 @@ import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { describe, it, expect, vi, beforeEach } from 'vitest';
// Utility mocks
global.fetch = vi.fn().mockResolvedValue({
json: () => Promise.resolve({}),
});
vi.mock('../../api.js', () => ({
default: {
getSDLineups: vi.fn().mockResolvedValue([]),