Automerge backed Markdown editor for the Atmosphere
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758/** * Tests for loadMathJax stub function. * * loadMathJax is a stub that: * 1. Returns a resolved Promise<void> immediately * 2. Emits a one-shot console.warn on first call per page-load * * The function exists for Obsidian API compatibility. Plugins that call * loadMathJax() to initialize MathJax rendering will not crash, but * actual math rendering is not supported (MathJax is not bundled). */
import { describe, it, expect, vi, beforeEach } from 'vitest'import { loadMathJax, _resetWarnedStubs } from '../obsidian-stubs'
beforeEach(() => { _resetWarnedStubs() vi.restoreAllMocks()})
describe('loadMathJax', () => { it('returns a resolved Promise<void>', async () => { const result = await loadMathJax() expect(result).toBeUndefined() })
it('emits a console.warn on first call', async () => { const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}) await loadMathJax() expect(warnSpy).toHaveBeenCalledOnce() expect(warnSpy).toHaveBeenCalledWith( expect.stringContaining('[Reams] loadMathJax') ) })
it('emits console.warn only once per page-load (warn-once)', async () => { const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}) await loadMathJax() await loadMathJax() await loadMathJax() 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 loadMathJax()).toBeUndefined() expect(await loadMathJax()).toBeUndefined() expect(await loadMathJax()).toBeUndefined() })})