test

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package test contains helper functions for prompt tests.

Index

Constants

This section is empty.

Variables

View Source
var (
	// UpdateGoldenFiles specifies whether the golden files should be updated.
	UpdateGoldenFiles = flag.Bool("update", false, "update the golden files")

	// Inspect prints string mismatches escaped such that the differences can be
	// inspected in detail.
	Inspect = flag.Bool("inspect", false, "inspect strings in detail")
)

Functions

func AssertGoldenView

func AssertGoldenView(tb testing.TB, m tea.Model, expectedViewFile string)

AssertGoldenView compares the view to an exected view in an updatable golden file.

func Indent

func Indent(text string) string

Indent is intended to indent views for easier comparison in test error logs.

func KeyMsg

func KeyMsg(r rune) tea.Msg

KeyMsg returns the KeyMsg that corresponds to the given rune.

func MsgsFromText

func MsgsFromText(text string) []tea.Msg

MsgsFromText generates KeyMsg events from a given text.

func Run

func Run(tb testing.TB, model tea.Model, events ...tea.Msg)

Run initializes the model and applies all events.

func StripANSI

func StripANSI(str string) string

StripANSI removes all ANSI sequences from a string.

func Update

func Update(tb testing.TB, model tea.Model, event tea.Msg) tea.Cmd

Update applies the event to an already initialized model. If the model was not initialized, use Run instead.

Types

This section is empty.

Jump to

Keyboard shortcuts

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