MCPcopy Create free account
hub / github.com/NV404/gova / TestRender

Function TestRender

testing.go:7–29  ·  view source on GitHub ↗

TestRender renders a component headlessly and returns a RenderedTree for querying and simulating interactions. No Fyne window is created.

(root View, opts ...TestOption)

Source from the content-addressed store, hash-verified

5// TestRender renders a component headlessly and returns a RenderedTree
6// for querying and simulating interactions. No Fyne window is created.
7func TestRender(root View, opts ...TestOption) *RenderedTree {
8 scope := newScope(context.Background(), nil)
9
10 for _, opt := range opts {
11 opt(scope)
12 }
13
14 var node *viewNode
15 if comp, ok := root.(*componentNode); ok {
16 rendered := renderComponent(comp, scope)
17 node = rendered.viewNode()
18 // Resolve nested components
19 node = resolveTree(node, scope)
20 } else {
21 node = root.viewNode()
22 }
23
24 rt := &RenderedTree{scope: scope, root: node, component: nil}
25 if comp, ok := root.(*componentNode); ok {
26 rt.component = comp
27 }
28 return rt
29}
30
31func resolveTree(node *viewNode, scope *Scope) *viewNode {
32 if node.componentRef != nil {

Callers 7

TestTestRenderCounterFunction · 0.85
TestTestRenderToggleFunction · 0.85
TestTestRenderTextFieldFunction · 0.85
TestTestRenderWithStoreFunction · 0.85
TestTestRenderNodeCountFunction · 0.85

Calls 5

newScopeFunction · 0.85
renderComponentFunction · 0.85
resolveTreeFunction · 0.85
BackgroundMethod · 0.80
viewNodeMethod · 0.65

Tested by

no test coverage detected