Documentation ¶
Overview ¶
Package grt contains utilities used to test React components. TODO(bep) Move this to its own repo maybe when it is more mature.
Index ¶
- func Equal(t *testing.T, expected, actual interface{})
- func Fail(t *testing.T, args ...interface{})
- func NotEqual(t *testing.T, v1, v2 interface{})
- func NotNil(t *testing.T, val interface{})
- type Matcher
- type RenderedTree
- func (t *RenderedTree) CallEventListener(name string, args ...interface{}) *js.Object
- func (t *RenderedTree) Dive(path ...string) *RenderedTree
- func (t *RenderedTree) ReRender(props gr.Props)
- func (t *RenderedTree) String() string
- func (t *RenderedTree) Sub(selector string, matchers ...Matcher) *RenderedTree
- func (t *RenderedTree) This() *gr.This
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Equal ¶
Equal is a test assertion used to check equality.
func Fail ¶
Fail fails the test with the given message.
func NotEqual ¶
NotEqual is a test assertion used to check non-equality.
Types ¶
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher used to find a component in the component tree.
type RenderedTree ¶
type RenderedTree struct { *js.Object GetMountedInstance func() *js.Object `js:"getMountedInstance"` Text func() string `js:"text"` // fillField: [Function], //findComponent: [Function], //findComponentLike: [Function], GetRenderOutput func() map[string]interface{} `js:"getRenderOutput"` Props *js.Object `js:"props"` Type string `js:"type"` // contains filtered or unexported fields }
RenderedTree represents a shallow render.
func ShallowRender ¶
func ShallowRender(c gr.Component) *RenderedTree
ShallowRender performs a shallow render of the given component.
func ShallowRenderWithContext ¶
func ShallowRenderWithContext(c gr.Component, ctx gr.Context) *RenderedTree
ShallowRenderWithContext performs a shallow render with the given context.
func (*RenderedTree) CallEventListener ¶
func (t *RenderedTree) CallEventListener(name string, args ...interface{}) *js.Object
CallEventListener is a convenience func to simulate button clicks etc. by calling the listener methods by name.
func (*RenderedTree) Dive ¶
func (t *RenderedTree) Dive(path ...string) *RenderedTree
Dive can be used to render a sub-component.
func (*RenderedTree) ReRender ¶
func (t *RenderedTree) ReRender(props gr.Props)
ReRender rerenders a component with new properties.
func (*RenderedTree) String ¶
func (t *RenderedTree) String() string
String represents a shallow rendered component. This is in heavy use in assertions, so we try to keep it stable.
func (*RenderedTree) Sub ¶
func (t *RenderedTree) Sub(selector string, matchers ...Matcher) *RenderedTree
Sub returns a sub component matching the matchers.
func (*RenderedTree) This ¶
func (t *RenderedTree) This() *gr.This
This returns the this context of a shallow render.