/** * @file * * Mock of Obsidian's `NullValue`, the Bases value that represents null. */ import type { NullValue as NullValueOriginal } from 'obsidian'; import type { RenderContext } from './RenderContext.cjs'; import { Value } from './Value.cjs'; /** * Mock of Obsidian's `NullValue`, the Bases value that represents null. * * A REAL singleton, as Obsidian's is: {@link NullValue.value} is the only way in, and a second construction * throws with Obsidian's own message. The one call that gets through is the static initializer below, which * runs while `NullValue.value` is still unset - exactly how Obsidian's `NullValue.value = new NullValue()` * passes its own guard. * * One consequence worth knowing before writing a test against it: because every null is the same object, * {@link Value.equals} and {@link Value.looseEquals} answer from their identity check and never reach * {@link NullValue.equals}. That is Obsidian's shape too, not a shortcut here. */ export declare class NullValue extends Value { /** * The value type's identifier, `'Null'` - Obsidian's own name for this class of value. */ static type: string; /** * The one null value. Obsidian's `NullValue` is a singleton and this is it; the constructor refuses * anything else. */ static value: NullValue; /** * Creates the one null value, and refuses every later attempt, as Obsidian does. * * The guard sits AFTER `super()` because Obsidian's does: its constructor calls the base, and only then * tests `NullValue.value`. So a refused construction still fires {@link Value.constructor__} and still * assigns {@link Value.icon} before it throws, and a spy on the base hook observes the same thing it * observes in the app. * * @throws When {@link NullValue.value} already holds the singleton. */ constructor(); /** * Mock-only factory: creates the null value, spyable via `vi.spyOn(NullValue, 'create__')`. * * Called exactly once, by the {@link NullValue.value} initializer at class-initialization time. Every later * call throws, because the constructor it delegates to refuses a second instance - so a spy installed from * a test can observe the factory, never make it answer. * * @returns The one null value. * @throws When {@link NullValue.value} already holds the singleton. */ static create__(): NullValue; /** * Mock-only: views a value typed as Obsidian's `NullValue` as this mock. * * @param value - The value typed as the original `NullValue`. * @returns The same object, typed as the mock. */ static fromOriginalType2__(value: NullValueOriginal): NullValue; /** * Mock-only: views this mock as Obsidian's `NullValue` type. * * @returns The same object, typed as the original `NullValue`. */ asOriginalType2__(): NullValueOriginal; /** * Mock-only construction hook, called at the end of the constructor; a no-op meant for * `vi.spyOn(NullValue.prototype, 'constructor2__')`. */ constructor2__(): void; /** * Compares this value with another null value, as Obsidian does. * * @param _other - The value to compare with; only the singleton itself ever reaches here, and only on a * direct call, because {@link Value.equals} answers from its identity check before its class test. * @returns Always `true`: one null is every other null - which, since there is only ever one, is a claim * about Obsidian's shape rather than about a comparison a consumer can arrange. */ equals(_other: this): boolean; /** * Reports whether the value counts as true in a condition; null never does. * * @returns Always `false`. */ isTruthy(): boolean; /** * Renders the value into an element: nothing at all, as Obsidian's override does. * * This is the one override in the hierarchy that renders LESS than its base. Obsidian's base writes the * value's string form, and a null writes nothing rather than the word `null` its {@link NullValue.toString} * answers - so the override is what keeps an empty cell empty, and dropping it would put `null` on screen. * * @param _el - The element to render into; left untouched. * @param _context - The rendering context; unused. */ renderTo(_el: HTMLElement, _context: RenderContext): void; /** * Converts the value to its display string. * * @returns Always `'null'`, the literal Obsidian prints. It is read further than it looks: * {@link ListValue.join} - and through it `ListValue.toString` - writes it into the joined text, and * {@link ListValue.unique} buckets by it, so a list holding a null shows and de-duplicates by this word. */ toString(): string; }