소스 정보
- 저장소
- dev-hann/song
- 최근 소스 활동
- 2026년 2월 18일 13:08
- 감지된 SKILL.md 언어
- 영어
- 스타
- 0
- 포크
- 0
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/dev-hann/song --skill hook-testing명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
Runs PM-Designer-Doc triple review protocol to reach consensus on feature specs before implementation. Includes domain documentation consistency check. Use before implementing any new screen, component, or significant feature.
Create Server and Client React components with proper props, state, and patterns
Enforce docs ↔ code consistency before and after implementation. Launches doc-reviewer agent to cross-check domain documentation against actual codebase, detects drift, and ensures documentation updates accompany code changes.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | hook-testing |
| description | Test React Hooks with proper state management and async handling using renderHook |
| license | MIT |
| compatibility | opencode |
| metadata | {"category":"testing","complexity":"intermediate"} |
renderHook from @testing-library/reactwaitForUse this when you need to:
I'll ask clarifying questions if:
import { describe, it, expect, beforeEach, vi } from 'vitest';
import { renderHook, waitFor } from '@testing-library/react';
import { useYouTubeSearch } from '@/hooks/use-youtube';
vi.mock('@/lib/api-helpers', () => ({
fetchAPI: vi.fn(),
}));
describe('useYouTubeSearch', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('should initialize with empty state', () => {
const { result } = renderHook(() => useYouTubeSearch());
expect(result.current.results).toBeNull();
expect(result.current.loading).toBe(false);
expect(result.current.error).toBe('');
});
});
describe('Async Operations', () => {
it('should fetch and display search results', async () => {
const mockData = {
results: [
{
id: 'video123',
type: 'video',
title: 'Test Video',
thumbnail: 'https://example.com/thumb.jpg',
channel: { name: 'Test Channel' },
},
],
};
const { fetchAPI } = await import('@/lib/api-helpers');
vi.mocked(fetchAPI).mockResolvedValue(mockData);
const { result } = renderHook(() => useYouTubeSearch());
await result.current.searchVideos('test query');
await waitFor(() => {
expect(result.current.results).toHaveLength(1);
expect(result.current.loading).toBe(false);
});
});
it('should handle search errors', () => {
{ fetchAPI } = ();
vi.(fetchAPI).( ());
{ result } = ( ());
result..();
( {
(result..).();
(result..).();
});
});
});
describe('Loading States', () => {
it('should set loading to true when searching', async () => {
const { fetchAPI } = await import('@/lib/api-helpers');
vi.mocked(fetchAPI).mockImplementation(
() => new Promise(() => {})
);
const { result } = renderHook(() => useYouTubeSearch());
result.current.searchVideos('test query');
expect(result.current.loading).toBe(true);
});
});
describe('State Updates', () => {
it('should update results on multiple searches', async () => {
const mockData1 = {
results: [{ id: 'video1', type: 'video', title: 'Video 1', thumbnail: 'https://example.com/thumb.jpg', channel: { name: 'Test Channel' } }],
};
const mockData2 = {
results: [{ id: 'video2', type: 'video', title: 'Video 2', thumbnail: 'https://example.com/thumb.jpg', channel: { name: 'Test Channel' } }],
};
const { fetchAPI } = await import('@/lib/api-helpers');
vi.mocked(fetchAPI)
.mockResolvedValueOnce(mockData1)
.mockResolvedValueOnce(mockData2);
const { result } = renderHook(() => useYouTubeSearch());
await result.current.searchVideos('query1');
await waitFor(() => {
(result..?.[]?.).();
});
result..();
( {
(result..?.[]?.).();
});
});
});
describe('Edge Cases', () => {
it('should not search with empty query', async () => {
const { fetchAPI } = await import('@/lib/api-helpers');
vi.mocked(fetchAPI).mockResolvedValue({ results: [] });
const { result } = renderHook(() => useYouTubeSearch());
await result.current.searchVideos('');
expect(fetchAPI).not.toHaveBeenCalled();
});
it('should handle null results', async () => {
const { fetchAPI } = await import('@/lib/api-helpers');
vi.mocked(fetchAPI).mockResolvedValue({ results: null });
const { result } = renderHook(() => useYouTubeSearch());
await result.current.searchVideos('test');
await waitFor(() => {
expect(result.current.).();
});
});
});
describe('useYouTubeSearch', () => {
describe('Initialization', () => {
it('should initialize with empty state');
});
describe('Loading States', () => {
it('should set loading to true when searching');
});
describe('Success Cases', () => {
it('should fetch and display search results');
it('should update results on multiple searches');
});
describe('Error Cases', () => {
it('should handle search errors');
it('should handle network errors');
});
describe('Edge Cases', () => {
it('should not search with empty query');
it('should handle null results');
});
});
describe('AAA Pattern Example', () => {
it('should fetch and display search results', async () => {
// Arrange
const mockData = { results: [{ id: 'video123', type: 'video', title: 'Test Video', thumbnail: 'https://example.com/thumb.jpg', channel: { name: 'Test Channel' } }] };
const { fetchAPI } = await import('@/lib/api-helpers');
vi.mocked(fetchAPI).mockResolvedValue(mockData);
// Act
const { result } = renderHook(() => useYouTubeSearch());
await result.current.searchVideos('test query');
// Assert
await waitFor(() => {
expect(result.current.results).toHaveLength(1);
expect(result.current.loading).toBe(false);
});
});
});
| Test Type | What to Test |
|---|---|
| Hook Initialization | Initial state values |
| Loading States | Loading flag during async operations |
| Success Cases | Correct data after successful operations |
| Error Cases | Error messages and state on failures |
| State Updates | State changes on subsequent calls |
| Edge Cases | Empty inputs, null values, etc. |
| Pattern | Description |
|---|---|
renderHook | Render a hook for testing |
waitFor | Wait for async state updates |
vi.clearAllMocks | Clear all mocks before each test |
vi.mocked | Type-safe mock access |
await import() | Lazy import for mocking |
Related SKILLS: component-testing.md, api-testing.md, utility-testing.md