Skip to content

HoverPopover

Mock of Obsidian’s HoverPopover.

Nothing is shown and no timer runs: the popover owns a detached HoverPopover.hoverEl and its state stays where it was set.

Import:

import { HoverPopover } from 'obsidian-test-mocks/obsidian';

Signature:

export class HoverPopover extends Component

Extends: Component

Constructor

new HoverPopover(parent: HoverParent, targetEl: HTMLElement | null, waitTime?: number | undefined, staticPos?: Point | null | undefined)

Creates a popover for a hover parent.

Properties

PropertyTypeDescription
_childrenComponent[]The child components, unloaded when this component unloads.
(Inherited from Component)
_eventsEventRefOriginal[]The event refs registered with Component.registerEvent, detached when this component unloads.
(Inherited from Component)
_loadedbooleanWhether this component is currently loaded.
(Inherited from Component)
cleanups__(() => unknown)[]Mock-only: the callbacks registered with Component.register, run in reverse order on unload.
(Inherited from Component)
hoverElHTMLElementThe popover's element, which holds the preview content.
intervals__number[]Mock-only: the interval ids registered with Component.registerInterval, cleared on unload.
(Inherited from Component)
statePopoverStateOriginalThe popover's lifecycle state (showing, hiding and so on); starts at 0.

Methods

MethodReturnsDescription
addChild(component)TAdds a child component, loading it if this component is already loaded.
(Inherited from Component)
asOriginalType__()ComponentOriginalMock-only: views this mock as Obsidian's Component type.
(Inherited from Component)
asOriginalType2__()HoverPopoverOriginalMock-only: views this mock as Obsidian's HoverPopover type.
constructor__()voidMock-only construction hook, called at the end of the constructor; a no-op meant for vi.spyOn(Component.prototype, 'constructor__').
(Inherited from Component)
constructor2__(_parent, _targetEl, _waitTime?, _staticPos?)voidMock-only construction hook, called at the end of the constructor; a no-op meant for vi.spyOn(HoverPopover.prototype, 'constructor2__').
load()voidLoads this component and then its children; does nothing if it is already loaded.
(Inherited from Component)
onload()voidCalled when the component loads; override it to set the component up. A no-op by default.
(Inherited from Component)
onunload()voidCalled when the component unloads; override it to tear the component down. A no-op by default.
(Inherited from Component)
register(callback)voidRegisters a callback to run when this component unloads.
(Inherited from Component)
registerDomEvent(el, type, callback, options?)voidAdds a DOM event listener, and registers a cleanup that removes it when this component unloads.
(Inherited from Component)
registerEvent(ref)voidRegisters an event ref to be detached, through its owning Events object's offref, when this component unloads.
(Inherited from Component)
registerInterval(id)numberRegisters an interval to be cleared with clearInterval when this component unloads.
(Inherited from Component)
removeChild(component)TRemoves a child component, if present, and unloads it.
(Inherited from Component)
unload()voidUnloads this component: unloads and forgets its children, runs its registered cleanups, clears the tracked events and intervals, then calls Component.onunload. Does nothing if it is not loaded.
(Inherited from Component)
static create__()ComponentMock-only factory: creates a component, spyable via vi.spyOn(Component, 'create__').
(Inherited from Component)
static create2__(parent, targetEl, waitTime?, staticPos?)HoverPopoverMock-only factory: creates a hover popover, spyable via vi.spyOn(HoverPopover, 'create2__'). The subclass variant of Component.create__.
static forLeaf__(_leaf)HoverPopover | nullMock-only: looks up the hover popover open for a leaf. The mock tracks none, so it always returns null.
static fromOriginalType__(value)ComponentMock-only: views a value typed as Obsidian's Component as this mock.
(Inherited from Component)
static fromOriginalType2__(value)HoverPopoverMock-only: views a value typed as Obsidian's HoverPopover as this mock.

Links to this page: