Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TNMXVCZXMpHpVvqmFkeChL
29 lines
894 B
TypeScript
29 lines
894 B
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
|
|
const info = vi.fn();
|
|
vi.mock('react-toastify', () => ({ toast: { info, success: vi.fn() } }));
|
|
vi.mock('../state', () => ({
|
|
getEntities: () => [],
|
|
isDrawingReadOnly: () => false,
|
|
resetUndoBaseline: vi.fn(),
|
|
setActiveLayerId: vi.fn(),
|
|
setEntities: vi.fn(),
|
|
setLayers: vi.fn(),
|
|
}));
|
|
|
|
describe('registerAutoSave', () => {
|
|
it('백업이 있어도 시작 토스트를 띄우지 않고 백업 듣기만 건다', async () => {
|
|
const addEventListener = vi.fn();
|
|
vi.stubGlobal('window', { addEventListener });
|
|
vi.stubGlobal('localStorage', {
|
|
getItem: () => JSON.stringify({ savedAt: 1, json: '{}' }),
|
|
setItem: vi.fn(),
|
|
removeItem: vi.fn(),
|
|
});
|
|
const { registerAutoSave } = await import('./autosave');
|
|
registerAutoSave();
|
|
expect(info).not.toHaveBeenCalled();
|
|
expect(addEventListener).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|