Files
terminalShop/pkg/tui/menu_test.go
marcusDenslow 1a49360191 feat: throw out the boolean navigation with page routing
replaced ViewingCart/ViewingAccount booleans and CheckoutStep int with a
single 'page' type and a SwitchPage() method, this is just almost
copying the reference implementation (terminalDotShop)'s routing
pattern. Adds inCartFlow(), chechoutStep(), and buildPageContent()
helpers to clean up those huge if/else chains in views, footer, header,
and breadcrumds. code is looking a lot better now!
2026-03-25 15:11:33 +01:00

99 lines
2.8 KiB
Go

package tui
import (
"terminalShop/pkg/api"
"terminalShop/pkg/models"
"testing"
gossh "golang.org/x/crypto/ssh"
)
func TestModel_BuildMenuView(t *testing.T) {
type fields struct {
User *models.User
IsNewUser bool
SSHPublicKey gossh.PublicKey
AccessToken string
UsernameInput string
Username string
Coffees []models.Coffee
Cursor int
Cart map[uint]*models.CartItem
CartCursor int
AccountCursor int
ScrollOffset int
currentPage page
viewportWidth int
viewportHeight int
widthContainer int
heightContainer int
widthContent int
size termSize
resizeSeq int
pendingWidth int
pendingHeight int
Loading bool
ErrorMsg string
APIClient *api.Client
ShippingForm *ShippingFormState
PaymentForm *PaymentFormState
ShippingInfo *models.Address
SavedAddresses []models.Address
ShippingView int
AddressCursor int
StripeKey string
Orders []models.Order
OrdersLoaded bool
}
tests := []struct {
name string
fields fields
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
m := Model{
User: tt.fields.User,
IsNewUser: tt.fields.IsNewUser,
SSHPublicKey: tt.fields.SSHPublicKey,
AccessToken: tt.fields.AccessToken,
UsernameInput: tt.fields.UsernameInput,
Username: tt.fields.Username,
Coffees: tt.fields.Coffees,
Cursor: tt.fields.Cursor,
Cart: tt.fields.Cart,
CartCursor: tt.fields.CartCursor,
AccountCursor: tt.fields.AccountCursor,
ScrollOffset: tt.fields.ScrollOffset,
currentPage: tt.fields.currentPage,
viewportWidth: tt.fields.viewportWidth,
viewportHeight: tt.fields.viewportHeight,
widthContainer: tt.fields.widthContainer,
heightContainer: tt.fields.heightContainer,
widthContent: tt.fields.widthContent,
size: tt.fields.size,
resizeSeq: tt.fields.resizeSeq,
pendingWidth: tt.fields.pendingWidth,
pendingHeight: tt.fields.pendingHeight,
Loading: tt.fields.Loading,
ErrorMsg: tt.fields.ErrorMsg,
APIClient: tt.fields.APIClient,
ShippingForm: tt.fields.ShippingForm,
PaymentForm: tt.fields.PaymentForm,
ShippingInfo: tt.fields.ShippingInfo,
SavedAddresses: tt.fields.SavedAddresses,
ShippingView: tt.fields.ShippingView,
AddressCursor: tt.fields.AddressCursor,
StripeKey: tt.fields.StripeKey,
Orders: tt.fields.Orders,
OrdersLoaded: tt.fields.OrdersLoaded,
}
if got := m.BuildMenuView(); got != tt.want {
t.Errorf("Model.BuildMenuView() = %v, want %v", got, tt.want)
}
})
}
}