Skip to content

IconValue

Mock of Obsidian’s IconValue: a string value holding an icon id.

Import:

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

Signature:

export class IconValue extends StringValue

Extends: StringValue

Constructor

new IconValue(value?: string)

Creates an icon value.

Properties

PropertyTypeDescription
iconstringThe lucide icon name standing for this value's type.
typestringThe value type's identifier, 'String' - Obsidian's own name for this class of value.
(Inherited from StringValue)

Methods

MethodReturnsDescription
asOriginalType4__()StringValueOriginalMock-only: views this mock as Obsidian's StringValue type.
(Inherited from StringValue)
asOriginalType5__()IconValueOriginalMock-only: views this mock as Obsidian's IconValue type.
constructor4__(_value?)voidMock-only construction hook, called at the end of the constructor; a no-op meant for vi.spyOn(StringValue.prototype, 'constructor4__').
(Inherited from StringValue)
constructor5__(_value)voidMock-only construction hook, called at the end of the constructor; a no-op meant for vi.spyOn(IconValue.prototype, 'constructor5__').
keys()string[]Lists the property keys StringValue.objectAccess answers for.
(Inherited from StringValue)
objectAccess(key)null | ValueReads a named sub-property of this value.
(Inherited from StringValue)
renderTo(el, _context)voidRenders the icon into an element, as Obsidian does: the SVG the icon id resolves to, falling back to question-mark-glyph when the id is unknown, and rendering NOTHING when even that does not resolve.

In practice the mock takes that last branch: src/internal/icon-registry.ts starts EMPTY on purpose - Obsidian's Lucide set and its own glyphs are deliberately not bundled - so both lookups answer null unless a test has registered the id with addIcon. That is a property of the registry rather than of this method: register question-mark-glyph and every unknown icon renders it, exactly as in the app.
static create__(value?)StringValueMock-only factory: creates a string value, spyable via vi.spyOn(StringValue, 'create__').
(Inherited from StringValue)
static create2__(value?)IconValueMock-only factory: creates an icon value, spyable via vi.spyOn(IconValue, 'create2__'). The subclass variant of StringValue.create__.
static fromOriginalType4__(value)StringValueMock-only: views a value typed as Obsidian's StringValue as this mock.
(Inherited from StringValue)
static fromOriginalType5__(value)IconValueMock-only: views a value typed as Obsidian's IconValue as this mock.