import { describe, expect, test } from 'bun:test' import { handlePostBodyMarkdownEditorViewportSwitch } from './post-body-markdown-editor-vditor-viewport' describe('PostBodyMarkdownEditor viewport switch', () => { test('断点未变化时不重建且返回 false', () => { let remountCalls = 0 const changed = handlePostBodyMarkdownEditorViewportSwitch({ currentIsMobile: false, nextIsMobile: false, hasMountedEditor: true, remountEditor: () => { remountCalls += 1 }, }) expect(changed).toBe(false) expect(remountCalls).toBe(0) }) test('断点变化且已挂载时会重建编辑器', () => { let remountCalls = 0 const changed = handlePostBodyMarkdownEditorViewportSwitch({ currentIsMobile: false, nextIsMobile: true, hasMountedEditor: true, remountEditor: () => { remountCalls += 1 }, }) expect(changed).toBe(true) expect(remountCalls).toBe(1) }) test('断点变化但未挂载时仅更新状态不重建', () => { let remountCalls = 0 const changed = handlePostBodyMarkdownEditorViewportSwitch({ currentIsMobile: true, nextIsMobile: false, hasMountedEditor: false, remountEditor: () => { remountCalls += 1 }, }) expect(changed).toBe(true) expect(remountCalls).toBe(0) }) })