Commit current project

This commit is contained in:
2026-03-29 22:44:13 +02:00
parent b3bccb2ae3
commit 7f9469c07d
77 changed files with 20495 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
import { describe, it, expect, beforeEach, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import YouTubeLinker from '../../src/components/YouTubeLinker';
import { addYoutubeLink } from '../../src/lib/youtubeLinks';
describe('YouTubeLinker component', () => {
beforeEach(() => {
localStorage.clear();
});
it('displays an existing link and allows removal', async () => {
const availableChannels = [
{ id: 'a', name: 'chanA', displayName: 'Channel A', title: 'Channel A title', profileImageUrl: '' },
{ id: 'b', name: 'chanB', displayName: 'Channel B', title: 'Channel B title', profileImageUrl: '' },
];
// Programmatically add a link
addYoutubeLink({
twitchChannelId: 'a',
twitchDisplayName: 'Channel A',
youtubeUrl: 'https://www.youtube.com/@channelA',
});
const onClose = vi.fn();
render(<YouTubeLinker availableChannels={availableChannels} onClose={onClose} />);
// The linked item should appear
expect(screen.getByText('Channel A')).toBeInTheDocument();
expect(screen.getByText('https://www.youtube.com/@channelA')).toBeInTheDocument();
// Remove via UI
const removeButton = screen.getByTitle('Remove YouTube link');
await userEvent.click(removeButton);
// Now the empty message should be shown
await screen.findByText('No YouTube channels linked yet');
const saved = JSON.parse(localStorage.getItem('mixchat_youtube_links') || '[]');
expect(saved).toHaveLength(0);
});
});