Skip to main content

MockDom

Struct MockDom 

Source
pub struct MockDom {
    pub root: DomElement,
    /* private fields */
}
Expand description

Mock DOM for testing WASM calculator without browser

Fields§

§root: DomElement

Root element

Implementations§

Source§

impl MockDom

Source

pub fn new() -> Self

Creates a new mock DOM

Source

pub fn calculator() -> Self

Creates a calculator DOM structure

Source

pub fn register_element(&mut self, element: DomElement)

Registers an element for ID lookup

Source

pub fn get_element(&self, id: &str) -> Option<&DomElement>

Gets an element by ID

Source

pub fn get_element_mut(&mut self, id: &str) -> Option<&mut DomElement>

Gets a mutable element by ID

Source

pub fn dispatch_event(&mut self, event: DomEvent)

Dispatches an event

Source

pub fn event_history(&self) -> &[DomEvent]

Gets the event history

Source

pub fn clear_event_history(&mut self)

Clears event history

Source

pub fn focused_element(&self) -> Option<&str>

Gets the currently focused element ID

Source

pub fn set_element_text(&mut self, id: &str, text: &str)

Updates element text by ID

Source

pub fn get_element_text(&self, id: &str) -> Option<&str>

Gets element text by ID

Source

pub fn append_child(&mut self, parent_id: &str, child: DomElement)

Adds a child element to a parent

Source

pub fn clear_children(&mut self, id: &str)

Clears children of an element

Trait Implementations§

Source§

impl Debug for MockDom

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MockDom

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl MockDomKeypadExt for MockDom

Source§

fn add_keypad(&mut self, keypad: &WasmKeypad)

Adds keypad to an existing calculator DOM

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.