Documentation
¶
Overview ¶
Package btesting provides testing helpers for BubblyUI components and composables.
This package contains utilities for testing BubblyUI components including mock contexts, lifecycle triggers, and composable helpers.
This package is an alias for github.com/newbpydev/bubblyui/pkg/bubbly/testing, providing a cleaner import path for users.
Features ¶
- Test context creation for isolated testing
- Lifecycle hook triggers (mount, update, unmount)
- Mock composables for unit testing
- Cleanup assertion helpers
Example ¶
import "github.com/newbpydev/bubblyui/testing/btesting"
func TestMyComponent(t *testing.T) {
ctx := btesting.NewTestContext()
// Test composable
state := btesting.MockComposable(ctx, 42)
assert.Equal(t, 42, state.Get())
// Trigger lifecycle
btesting.TriggerMount(ctx)
btesting.TriggerUpdate(ctx)
btesting.TriggerUnmount(ctx)
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NewTestContext = btestingpkg.NewTestContext
NewTestContext creates a new test context for isolated testing.
var SetParent = btestingpkg.SetParent
SetParent sets the parent context for a child context.
var TriggerMount = btestingpkg.TriggerMount
TriggerMount triggers the mount lifecycle for a context.
var TriggerUnmount = btestingpkg.TriggerUnmount
TriggerUnmount triggers the unmount lifecycle for a context.
var TriggerUpdate = btestingpkg.TriggerUpdate
TriggerUpdate triggers the update lifecycle for a context.
Functions ¶
func AssertComposableCleanup ¶
AssertComposableCleanup asserts that a cleanup function was called.
func MockComposable ¶
func MockComposable[T any](ctx *bubbly.Context, value T) composables.UseStateReturn[T]
MockComposable creates a mock composable state for testing.
Types ¶
This section is empty.