Skip to content

BooleanValue

Mock of Obsidian’s BooleanValue, a Bases Value wrapping a boolean.

Import:

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

Signature:

export class BooleanValue extends PrimitiveValue<boolean>

Extends: PrimitiveValue<boolean>

Constructor

new BooleanValue(value?: boolean)

Creates a value wrapping a boolean.

Properties

PropertyTypeDescription
databooleanThe wrapped primitive. Obsidian's own name for it, which is why this carries no __ suffix (L4).
(Inherited from PrimitiveValue)
iconstringThe lucide icon name standing for this value's type.
typestringThe value type's identifier, 'Boolean' - Obsidian's own name for this class of value.

Methods

MethodReturnsDescription
asOriginalType3__()PrimitiveValueOriginal<boolean>Mock-only: views this mock as Obsidian's PrimitiveValue type.
(Inherited from PrimitiveValue)
asOriginalType4__()BooleanValueOriginalMock-only: views this mock as Obsidian's BooleanValue type. Numbered to avoid clashing with the variants its base classes declare.
constructor3__(_value)voidMock-only construction hook, called at the end of the constructor; a no-op meant for vi.spyOn(PrimitiveValue.prototype, 'constructor3__').
(Inherited from PrimitiveValue)
constructor4__(_value?)voidMock-only construction hook, called at the end of the constructor; a no-op meant for vi.spyOn(BooleanValue.prototype, 'constructor4__').
equals(other)booleanCompares this value with another of the same type, as Obsidian does: by strict equality of the wrapped primitives.
(Inherited from PrimitiveValue)
isTruthy()booleanReports whether the value counts as true in a condition, by JavaScript truthiness of the wrapped primitive.
(Inherited from PrimitiveValue)
looseEquals(other)booleanLoosely 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 PrimitiveValue)
renderTo(el, _context)voidRenders the value into an element, as Obsidian does: a DISABLED checkbox whose checked is the wrapped boolean, rather than the text true or false its base would write.

Obsidian sets checked as a PROPERTY after creating the input, not as an attribute, so the rendered element's checked attribute is absent either way and only inputEl.checked answers - which is what a consumer asserting on it has to read.
toString()stringConverts the value to its display string.
(Inherited from PrimitiveValue)
static create__(value?)BooleanValueMock-only factory: creates a boolean value, spyable via vi.spyOn(BooleanValue, 'create__').
static fromOriginalType3__(value)PrimitiveValue<boolean>Mock-only: views a value typed as Obsidian's PrimitiveValue as this mock.
(Inherited from PrimitiveValue)
static fromOriginalType4__(value)BooleanValueMock-only: views a value typed as Obsidian's BooleanValue as this mock. Numbered to avoid clashing with the variants its base classes declare.