33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
|
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||
|
|
import { renderHook } from '@testing-library/react';
|
||
|
|
import { useCastSupport } from './useCastSupport';
|
||
|
|
|
||
|
|
describe('useCastSupport', () => {
|
||
|
|
beforeEach(() => {
|
||
|
|
vi.clearAllMocks();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('should report cast as unavailable by default', () => {
|
||
|
|
const { result } = renderHook(() => useCastSupport());
|
||
|
|
expect(result.current.isAvailable).toBe(false);
|
||
|
|
expect(result.current.isConnected).toBe(false);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('should provide requestSession callback', () => {
|
||
|
|
const { result } = renderHook(() => useCastSupport());
|
||
|
|
expect(typeof result.current.requestSession).toBe('function');
|
||
|
|
// Should not throw
|
||
|
|
result.current.requestSession();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('should detect Chrome Cast when available', () => {
|
||
|
|
(window as Window & { chrome?: { cast?: { isAvailable?: boolean } } }).chrome = {
|
||
|
|
cast: { isAvailable: true },
|
||
|
|
};
|
||
|
|
const { result } = renderHook(() => useCastSupport());
|
||
|
|
expect(result.current.isAvailable).toBe(true);
|
||
|
|
// Cleanup
|
||
|
|
delete (window as Window & { chrome?: unknown }).chrome;
|
||
|
|
});
|
||
|
|
});
|