From df0c1b3429f18aebdc15aebd070774eb9ccb5a41 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Mon, 27 Jan 2025 01:25:01 +0300 Subject: [PATCH] added TestQuitWithHelp and TestShowBlockedAccount --- handlers/application/menuhandler_test.go | 67 ++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/handlers/application/menuhandler_test.go b/handlers/application/menuhandler_test.go index 918900b..7b4ea42 100644 --- a/handlers/application/menuhandler_test.go +++ b/handlers/application/menuhandler_test.go @@ -2759,3 +2759,70 @@ func TestMaxAmount(t *testing.T) { }) } } + +func TestQuitWithHelp(t *testing.T) { + fm, err := NewFlagManager(flagsPath) + if err != nil { + t.Logf(err.Error()) + } + flag_account_authorized, _ := fm.GetFlag("flag_account_authorized") + + sessionId := "session123" + + ctx := context.WithValue(context.Background(), "SessionId", sessionId) + + h := &MenuHandlers{ + flagManager: fm, + } + tests := []struct { + name string + input []byte + status string + expectedResult resource.Result + }{ + { + name: "Test quit with help message", + expectedResult: resource.Result{ + FlagReset: []uint32{flag_account_authorized}, + Content: "For more help, please call: 0757628885", + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + res, _ := h.QuitWithHelp(ctx, "quit_with_help", tt.input) + //Assert that the aflag_account_authorized has been reset to the result + assert.Equal(t, res, tt.expectedResult, "Expected result should be equal to the actual result") + }) + } +} + +func TestShowBlockedAccount(t *testing.T) { + sessionId := "session123" + ctx := context.WithValue(context.Background(), "SessionId", sessionId) + + h := &MenuHandlers{} + + tests := []struct { + name string + input []byte + status string + expectedResult resource.Result + }{ + { + name: "Test quit with Show Blocked Account", + expectedResult: resource.Result{ + Content: "Your account has been locked. For help on how to unblock your account, contact support at: 0757628885", + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + res, _ := h.ShowBlockedAccount(ctx, "show_blocked_account", tt.input) + //Assert that the result is as expected + assert.Equal(t, res, tt.expectedResult, "Expected result should be equal to the actual result") + }) + } +}