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
| Property | Type | Description |
|---|---|---|
| data | boolean | The wrapped primitive. Obsidian's own name for it, which is why this carries no __ suffix (L4).(Inherited from PrimitiveValue) |
| icon | string | The lucide icon name standing for this value's type. |
| type | string | The value type's identifier, 'Boolean' - Obsidian's own name for this class of value. |
Methods
| Method | Returns | Description |
|---|---|---|
| asOriginalType__() | ValueOriginal | Mock-only: views this mock as Obsidian's Value type.(Inherited from PrimitiveValue) |
| asOriginalType2__() | NotNullValueOriginal | Mock-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__() | BooleanValueOriginal | Mock-only: views this mock as Obsidian's BooleanValue type. Numbered to avoid clashing with the variants its base classes declare. |
| 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 PrimitiveValue) |
| 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 PrimitiveValue) |
| 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 PrimitiveValue) |
| constructor4__(_value?) | void | Mock-only construction hook, called at the end of the constructor; a no-op meant for vi.spyOn(BooleanValue.prototype, 'constructor4__'). |
| equals(other) | boolean | Compares this value with another of the same type, as Obsidian does: by strict equality of the wrapped primitives. (Inherited from PrimitiveValue) |
| equals(_other) | boolean | Compares this value with another of the same type. (Inherited from PrimitiveValue) |
| isTruthy() | boolean | Reports 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) | 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 PrimitiveValue) |
| looseEquals(_other) | boolean | Compares this value with a value of any type. (Inherited from PrimitiveValue) |
| objectAccess(_key) | null | Value | Reads a named sub-property of this value, as a Bases formula's . access does.(Inherited from PrimitiveValue) |
| renderTo(el, _context) | void | Renders 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() | string | Converts the value to its display string. (Inherited from PrimitiveValue) |
| static create__(value?) | BooleanValue | Mock-only factory: creates a boolean value, spyable via vi.spyOn(BooleanValue, '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 PrimitiveValue) |
| static fromOriginalType__(value) | Value | Mock-only: views a value typed as Obsidian's Value as this mock.(Inherited from PrimitiveValue) |
| static fromOriginalType2__(value) | NotNullValue | Mock-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) | BooleanValue | Mock-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) | 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 PrimitiveValue) |