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
asOriginalType__()ValueOriginalMock-only: views this mock as Obsidian's Value type.
(Inherited from PrimitiveValue)
asOriginalType2__()NotNullValueOriginalMock-only: views this mock as Obsidian's NotNullValue type.
(Inherited from PrimitiveValue)
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.
constructor__()voidMock-only construction hook, called at the end of the constructor; a no-op meant for vi.spyOn(Value.prototype, 'constructor__').
(Inherited from PrimitiveValue)
constructor2__()voidMock-only construction hook, called at the end of the constructor; a no-op meant for vi.spyOn(NotNullValue.prototype, 'constructor2__').
(Inherited from PrimitiveValue)
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)
equals(_other)booleanCompares this value with another of the same type.
(Inherited from PrimitiveValue)
isTruthy()booleanReports whether the value counts as true in a condition, by JavaScript truthiness of the wrapped primitive.
(Inherited from PrimitiveValue)
keys()string[]Lists the property keys Value.objectAccess answers for, which is what a Bases formula's . access can reach on this value.
(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)
looseEquals(_other)booleanCompares this value with a value of any type.
(Inherited from PrimitiveValue)
objectAccess(_key)null | ValueReads a named sub-property of this value, as a Bases formula's . access does.
(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 equals(this, a, b)booleanCompares 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 PrimitiveValue)
static fromOriginalType__(value)ValueMock-only: views a value typed as Obsidian's Value as this mock.
(Inherited from PrimitiveValue)
static fromOriginalType2__(value)NotNullValueMock-only: views a value typed as Obsidian's NotNullValue as this mock.
(Inherited from PrimitiveValue)
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.
static looseEquals(this, a, b)booleanLoosely 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 PrimitiveValue)