grt

package
v0.0.0-...-52c9d7f Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(t *testing.T, expected, actual interface{})

Equal is a test assertion used to check equality.

func Fail

func Fail(t *testing.T, args ...interface{})

Fail fails the test with the given message.

func NotEqual

func NotEqual(t *testing.T, v1, v2 interface{})

NotEqual is a test assertion used to check non-equality.

func NotNil

func NotNil(t *testing.T, val interface{})

NotNil is a test assertion that checks for both nil values and js.Undefined.

Types

type Matcher

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

Matcher used to find a component in the component tree.

func NewMatcher

func NewMatcher(key, value string) Matcher

NewMatcher creates a new matcher.

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.

Jump to

Keyboard shortcuts

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