mockdom

package
v4.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DOMOperation

type DOMOperation struct {
	Type      string
	NodeID    int
	ParentID  int
	Data      any
	Timestamp time.Time
}

DOMOperation records a DOM operation for testing

type MockDOMAdapter

type MockDOMAdapter struct {
	// contains filtered or unexported fields
}

MockDOMAdapter implements runtime.DOMAdapter

func NewMockDOMAdapter

func NewMockDOMAdapter() *MockDOMAdapter

NewMockDOMAdapter creates an empty MockDOMAdapter suitable for unit testing DOM operations.

func (*MockDOMAdapter) AppendChild

func (parseA *MockDOMAdapter) AppendChild(parseParent, parseChild runtime.DOMNode)

func (*MockDOMAdapter) AssertOperation

func (parseA *MockDOMAdapter) AssertOperation(parseIndex int, parseExpectedType string) error

AssertOperation verifies one recorded operation type at one log index.

func (*MockDOMAdapter) ClearOperations

func (parseA *MockDOMAdapter) ClearOperations()

ClearOperations resets the recorded DOM operation log.

func (*MockDOMAdapter) CreateElement

func (parseA *MockDOMAdapter) CreateElement(parseTag string) runtime.DOMNode

func (*MockDOMAdapter) CreateHTMLFragment added in v4.2.0

func (parseA *MockDOMAdapter) CreateHTMLFragment(parseHTML string) runtime.DOMNode

CreateHTMLFragment parses several serialized sibling subtrees into a detached container node whose children are the parsed roots, mirroring the browser adapter's template-content fragment. Appending a child elsewhere moves it out (AppendChild reparents).

func (*MockDOMAdapter) CreateHTMLSubtree added in v4.1.0

func (parseA *MockDOMAdapter) CreateHTMLSubtree(parseHTML string) runtime.DOMNode

CreateHTMLSubtree parses one serialized HTML subtree into mock nodes so the native suite exercises the same serialized-mount strategy the browser adapter uses (one parse, then the runtime's binding walk).

func (*MockDOMAdapter) CreateTextNode

func (parseA *MockDOMAdapter) CreateTextNode(parseText string) runtime.DOMNode

func (*MockDOMAdapter) GetAttribute

func (parseA *MockDOMAdapter) GetAttribute(parseNode runtime.DOMNode, parseName string) string

GetAttribute reports one stored attribute value for one mock DOM node.

func (*MockDOMAdapter) GetChildren

func (parseA *MockDOMAdapter) GetChildren(parseNode runtime.DOMNode) []runtime.DOMNode

func (*MockDOMAdapter) GetFirstChild

func (parseA *MockDOMAdapter) GetFirstChild(parseNode runtime.DOMNode) runtime.DOMNode

func (*MockDOMAdapter) GetNextSibling

func (parseA *MockDOMAdapter) GetNextSibling(parseNode runtime.DOMNode) runtime.DOMNode

func (*MockDOMAdapter) GetNode

func (parseA *MockDOMAdapter) GetNode(parseId int) *MockDOMNode

GetNode returns one live node handle for read-only assertions against adapter-owned state.

func (*MockDOMAdapter) GetOperations

func (parseA *MockDOMAdapter) GetOperations() []DOMOperation

GetOperations returns one snapshot copy of the recorded DOM operation log for assertions.

func (*MockDOMAdapter) GetParent

func (parseA *MockDOMAdapter) GetParent(parseNode runtime.DOMNode) runtime.DOMNode

func (*MockDOMAdapter) GetProperty

func (parseA *MockDOMAdapter) GetProperty(parseNode runtime.DOMNode, parseName string) any

func (*MockDOMAdapter) InsertBefore

func (parseA *MockDOMAdapter) InsertBefore(parseParent, parseNewNode, parseReferenceNode runtime.DOMNode)

func (*MockDOMAdapter) QuerySelector

func (parseA *MockDOMAdapter) QuerySelector(parseSelector string) any

QuerySelector resolves one simple selector against the current mock DOM tree.

The mock adapter only needs the subset used by framework tests: `#id` lookup plus a basic tag-name fallback when no id selector is requested.

func (*MockDOMAdapter) RemoveAttribute

func (parseA *MockDOMAdapter) RemoveAttribute(parseNode runtime.DOMNode, parseName string)

func (*MockDOMAdapter) RemoveChild

func (parseA *MockDOMAdapter) RemoveChild(parseParent, parseChild runtime.DOMNode)

func (*MockDOMAdapter) ReplaceChild

func (parseA *MockDOMAdapter) ReplaceChild(parseParent, parseNewNode, parseOldNode runtime.DOMNode)

func (*MockDOMAdapter) ReplaceChildren added in v4.2.0

func (parseA *MockDOMAdapter) ReplaceChildren(parseParent runtime.DOMNode, parseChildren []runtime.DOMNode)

ReplaceChildren replaces one parent's child list in a single operation, mirroring the browser adapter's Element.replaceChildren fidelity: listed nodes are reparented in order, unlisted previous children are detached.

func (*MockDOMAdapter) SetAttribute

func (parseA *MockDOMAdapter) SetAttribute(parseNode runtime.DOMNode, parseName, parseValue string)

func (*MockDOMAdapter) SetInnerHTML

func (parseA *MockDOMAdapter) SetInnerHTML(parseNode runtime.DOMNode, parseHtml string)

func (*MockDOMAdapter) SetProperty

func (parseA *MockDOMAdapter) SetProperty(parseNode runtime.DOMNode, parseName string, parseValue any)

func (*MockDOMAdapter) SetStyle

func (parseA *MockDOMAdapter) SetStyle(parseNode runtime.DOMNode, parseProperty, parseValue string)

func (*MockDOMAdapter) SetStyles

func (parseA *MockDOMAdapter) SetStyles(parseNode runtime.DOMNode, parseStyles map[string]string)

func (*MockDOMAdapter) SetTextContent

func (parseA *MockDOMAdapter) SetTextContent(parseNode runtime.DOMNode, parseText string)

func (*MockDOMAdapter) WrapFunction

func (parseA *MockDOMAdapter) WrapFunction(parseFn any) any

type MockDOMNode

type MockDOMNode struct {
	ID          int
	Tag         string
	TextContent string
	Attrs       map[string]string
	Props       map[string]any
	Styles      map[string]string
	InnerHTML   string
	Children    []*MockDOMNode
	Parent      *MockDOMNode
}

MockDOMNode implements runtime.DOMNode

func (*MockDOMNode) Equals

func (parseN *MockDOMNode) Equals(parseOther runtime.DOMNode) bool

func (*MockDOMNode) IsNull

func (parseN *MockDOMNode) IsNull() bool

type MockDeadline

type MockDeadline struct {
	// contains filtered or unexported fields
}

MockDeadline implements runtime.Deadline

func (*MockDeadline) DidTimeout

func (parseD *MockDeadline) DidTimeout() bool

func (*MockDeadline) TimeRemaining

func (parseD *MockDeadline) TimeRemaining() float64

type MockScheduler

type MockScheduler struct {
	// contains filtered or unexported fields
}

MockScheduler implements runtime.Scheduler for testing

func NewMockScheduler

func NewMockScheduler(isSynchronous bool) *MockScheduler

NewMockScheduler creates a MockScheduler; when synchronous is true callbacks are executed inline.

func (*MockScheduler) FlushAll

func (parseS *MockScheduler) FlushAll()

FlushAll executes all queued idle callbacks and timeouts until the scheduler settles.

func (*MockScheduler) FlushIdleCallbacks

func (parseS *MockScheduler) FlushIdleCallbacks()

FlushIdleCallbacks executes all pending idle callbacks

func (*MockScheduler) FlushTimeouts

func (parseS *MockScheduler) FlushTimeouts()

FlushTimeouts executes all pending timeouts

func (*MockScheduler) GetPendingCount

func (parseS *MockScheduler) GetPendingCount() int

GetPendingCount returns the number of pending callbacks

func (*MockScheduler) GetPendingTimeoutCount

func (parseS *MockScheduler) GetPendingTimeoutCount() int

GetPendingTimeoutCount returns the number of queued timeouts.

func (*MockScheduler) RequestIdleCallback

func (parseS *MockScheduler) RequestIdleCallback(parseCallback func(deadline runtime.Deadline))

func (*MockScheduler) SetTimeout

func (parseS *MockScheduler) SetTimeout(parseCallback func(), parseDelay int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL