Automerge backed Markdown editor for the Atmosphere
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758/** * Tests for loadPdfJs stub function. * * loadPdfJs is a stub that: * 1. Returns a resolved Promise<any> (resolving to undefined) * 2. Emits a one-shot console.warn on first call per page-load * * The function exists for Obsidian API compatibility. Plugins that call * loadPdfJs() to initialize PDF.js rendering will not crash, but * actual PDF rendering is not supported (PDF.js is not bundled). */
import { describe, it, expect, vi, beforeEach } from 'vitest'import { loadPdfJs, _resetWarnedStubs } from '../obsidian-stubs'
beforeEach(() => { _resetWarnedStubs() vi.restoreAllMocks()})
describe('loadPdfJs', () => { it('returns a resolved Promise<any> (undefined)', async () => { const result = await loadPdfJs() expect(result).toBeUndefined() })
it('emits a console.warn on first call', async () => { const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {})
await loadPdfJs()
expect(warnSpy).toHaveBeenCalledOnce() expect(warnSpy).toHaveBeenCalledWith( expect.stringContaining('[Reams] loadPdfJs') ) })
it('emits console.warn only once per page-load (warn-once)', async () => { const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {})
await loadPdfJs() await loadPdfJs() await loadPdfJs()
expect(warnSpy).toHaveBeenCalledOnce() })
it('can be called multiple times without error', async () => { // Suppress console.warn for cleaner test output vi.spyOn(console, 'warn').mockImplementation(() => {})
// Should not throw, all calls resolve to undefined expect(await loadPdfJs()).toBeUndefined() expect(await loadPdfJs()).toBeUndefined() expect(await loadPdfJs()).toBeUndefined() })})