btesting

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 4 Imported by: 0

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

View Source
var NewTestContext = btestingpkg.NewTestContext

NewTestContext creates a new test context for isolated testing.

SetParent sets the parent context for a child context.

View Source
var TriggerMount = btestingpkg.TriggerMount

TriggerMount triggers the mount lifecycle for a context.

View Source
var TriggerUnmount = btestingpkg.TriggerUnmount

TriggerUnmount triggers the unmount lifecycle for a context.

View Source
var TriggerUpdate = btestingpkg.TriggerUpdate

TriggerUpdate triggers the update lifecycle for a context.

Functions

func AssertComposableCleanup

func AssertComposableCleanup(t *testing.T, cleanup func())

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.

Jump to

Keyboard shortcuts

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