browser

package
v0.0.0-...-c923896 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package browser contains mocked Executor implementations for the use in unit tests.

Index

Constants

This section is empty.

Variables

View Source
var (
	// URL which is used in the simulated network event.
	URL = "http://foo.bar"

	// Status used in the simulated network event.
	Status = int64(200)

	// StatusText used in the simulated network event.
	StatusText = "Testing OK"

	// ConnectStart value used in the simulated network event.
	ConnectStart = float64(60)

	// ReceiveHeadersEnd value used in the simulated network event.
	ReceiveHeadersEnd = float64(100)
)

Functions

This section is empty.

Types

type CachedTestExecutor

type CachedTestExecutor struct {
	mock.Mock
}

CachedTestExecutor implements the Executor interface and can be used in tests as a testify mock object. It simulates a cached network event while listening for a devtools target event.

func NewCachedTestExecutor

func NewCachedTestExecutor() *CachedTestExecutor

NewCachedTestExecutor returns a new CachedTestExecutor.

func (*CachedTestExecutor) ListenTarget

func (e *CachedTestExecutor) ListenTarget(ctx context.Context, fn func(ev interface{}))

ListenTarget registers the method parameters, which can be asserted in unit tets. It also generates a network event object containing a cached result to test correct event listening behaviour.

func (*CachedTestExecutor) Run

func (e *CachedTestExecutor) Run(ctx context.Context, actions ...chromedp.Action) error

Run registers the method parameters and returns an error value declared by a testify mock setup. This can be used to assert a correct method call.

type EventTestExecutor

type EventTestExecutor struct {
	mock.Mock
}

EventTestExecutor implements the Executor interface and can be used in tests as a testify mock object. It simulates a network event while listening for a devtools target event.

func NewEventTestExecutor

func NewEventTestExecutor() *EventTestExecutor

NewEventTestExecutor returns a new EventTestExecutor.

func (*EventTestExecutor) ListenTarget

func (e *EventTestExecutor) ListenTarget(ctx context.Context, fn func(ev interface{}))

ListenTarget registers the method parameters, which can be asserted in unit tets. It also generates a network event object containing a cached result to test correct event listening behaviour.

func (*EventTestExecutor) Run

func (e *EventTestExecutor) Run(ctx context.Context, actions ...chromedp.Action) error

Run registers the method parameters and returns an error value declared by a testify mock setup. This can be used to assert a correct method call.

type TestExecutor

type TestExecutor struct {
	mock.Mock
}

TestExecutor implements the Executor interface and can be used in tests as a testify mock object.

func NewTestExecutor

func NewTestExecutor() *TestExecutor

NewTestExecutor returns a new TestExecutor.

func (*TestExecutor) ListenTarget

func (e *TestExecutor) ListenTarget(ctx context.Context, fn func(ev interface{}))

ListenTarget registers the method parameters, which can be asserted in unit tets.

func (*TestExecutor) Run

func (e *TestExecutor) Run(ctx context.Context, actions ...chromedp.Action) error

Run registers the method parameters and returns an error value declared by a testify mock setup. This can be used to assert a correct method call.

Jump to

Keyboard shortcuts

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