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 StringValueExtends: StringValue
Constructor
new IconValue(value?: string)Creates an icon value.
Properties
| Property | Type | Description |
|---|---|---|
| data | string | The wrapped primitive. Obsidian's own name for it, which is why this carries no __ suffix (L4).(Inherited from StringValue) |
| icon | string | The lucide icon name standing for this value's type. |
| type | string | The value type's identifier, 'String' - Obsidian's own name for this class of value.(Inherited from StringValue) |
Methods
| Method | Returns | Description |
|---|---|---|
| asOriginalType__() | ValueOriginal | Mock-only: views this mock as Obsidian's Value type.(Inherited from StringValue) |
| asOriginalType2__() | NotNullValueOriginal | Mock-only: views this mock as Obsidian's NotNullValue type.(Inherited from StringValue) |
| asOriginalType3__() | PrimitiveValueOriginal<string> | Mock-only: views this mock as Obsidian's PrimitiveValue type.(Inherited from StringValue) |
| asOriginalType4__() | StringValueOriginal | Mock-only: views this mock as Obsidian's StringValue type.(Inherited from StringValue) |
| asOriginalType5__() | IconValueOriginal | Mock-only: views this mock as Obsidian's IconValue type. |
| constructor__() | void | Mock-only construction hook, called at the end of the constructor; a no-op meant for vi.spyOn(Value.prototype, 'constructor__').(Inherited from StringValue) |
| constructor2__() | void | Mock-only construction hook, called at the end of the constructor; a no-op meant for vi.spyOn(NotNullValue.prototype, 'constructor2__').(Inherited from StringValue) |
| constructor3__(_value) | void | Mock-only construction hook, called at the end of the constructor; a no-op meant for vi.spyOn(PrimitiveValue.prototype, 'constructor3__').(Inherited from StringValue) |
| constructor4__(_value?) | void | Mock-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) | void | Mock-only construction hook, called at the end of the constructor; a no-op meant for vi.spyOn(IconValue.prototype, 'constructor5__'). |
| equals(other) | boolean | Compares this value with another of the same type, as Obsidian does: by strict equality of the wrapped primitives. (Inherited from StringValue) |
| equals(_other) | boolean | Compares this value with another of the same type. (Inherited from StringValue) |
| isTruthy() | boolean | Reports whether the value counts as true in a condition, by JavaScript truthiness of the wrapped primitive. (Inherited from StringValue) |
| keys() | string[] | Lists the property keys StringValue.objectAccess answers for. (Inherited from StringValue) |
| looseEquals(other) | boolean | Loosely compares this value with a value of any type, as Obsidian does: any other primitive value whose wrapped primitive is LOOSELY equal to this one. The == is Obsidian's own and is the whole point of the override - it is what makes BooleanValue(true) loosely equal NumberValue(1) and StringValue('1').(Inherited from StringValue) |
| looseEquals(_other) | boolean | Compares this value with a value of any type. (Inherited from StringValue) |
| objectAccess(key) | null | Value | Reads a named sub-property of this value. (Inherited from StringValue) |
| objectAccess(_key) | null | Value | Reads a named sub-property of this value, as a Bases formula's . access does.(Inherited from StringValue) |
| renderTo(el, _context) | void | Renders 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. |
| toString() | string | Converts the value to its display string. (Inherited from StringValue) |
| static create__(value?) | StringValue | Mock-only factory: creates a string value, spyable via vi.spyOn(StringValue, 'create__').(Inherited from StringValue) |
| static create2__(value?) | IconValue | Mock-only factory: creates an icon value, spyable via vi.spyOn(IconValue, 'create2__'). The subclass variant of StringValue.create__. |
| static equals(this, a, b) | boolean | Compares two possibly-null values, exactly as Obsidian's own static does: the same object is equal to itself, a missing value equals only another missing one, two values of DIFFERENT classes are never equal, and otherwise a.equals(b) decides. The missing test is Obsidian's own truthiness check rather than a null one, so an undefined the declared signature does not admit, but a JavaScript consumer can still pass, is answered rather than dereferenced.The class test is what lets each subclass's equals assume the other side is its own shape: PrimitiveValue.equals reads other.data, DateValue.equals reads other.time, and neither has to guard, because a value of another class never reaches them through this static.(Inherited from StringValue) |
| static fromOriginalType__(value) | Value | Mock-only: views a value typed as Obsidian's Value as this mock.(Inherited from StringValue) |
| static fromOriginalType2__(value) | NotNullValue | Mock-only: views a value typed as Obsidian's NotNullValue as this mock.(Inherited from StringValue) |
| static fromOriginalType3__(value) | PrimitiveValue<string> | Mock-only: views a value typed as Obsidian's PrimitiveValue as this mock.(Inherited from StringValue) |
| static fromOriginalType4__(value) | StringValue | Mock-only: views a value typed as Obsidian's StringValue as this mock.(Inherited from StringValue) |
| static fromOriginalType5__(value) | IconValue | Mock-only: views a value typed as Obsidian's IconValue as this mock. |
| static looseEquals(this, a, b) | boolean | Loosely compares two possibly-null values, exactly as Obsidian's own static does: the same object is loosely equal to itself, a missing value only to another missing one - by the truthiness test the static equals above describes - and otherwise strict equality is tried first, then a.looseEquals(b), then b.looseEquals(a).BOTH directions are tried, and that matters wherever the two sides' overrides disagree: it is what lets a one-element ListValue unwrap against a non-list whichever side it is passed on, and what lets a DateValue and a StringValue holding its text compare equal in either order.(Inherited from StringValue) |