diff --git a/internal/handlers/ussd/menuhandler_test.go b/internal/handlers/ussd/menuhandler_test.go index 6f1d57a..c2629c4 100644 --- a/internal/handlers/ussd/menuhandler_test.go +++ b/internal/handlers/ussd/menuhandler_test.go @@ -1498,10 +1498,10 @@ func TestValidateRecipient(t *testing.T) { }{ { name: "Test with invalid recepient", - input: []byte("9234adf5"), + input: []byte("7?1234"), expectedResult: resource.Result{ FlagSet: []uint32{flag_invalid_recipient}, - Content: "9234adf5", + Content: "7?1234", }, }, { @@ -1517,22 +1517,40 @@ func TestValidateRecipient(t *testing.T) { input: []byte("0711223344"), expectedResult: resource.Result{}, }, + { + name: "Test with address", + input: []byte("0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9"), + expectedResult: resource.Result{}, + }, + { + name: "Test with alias recepient", + input: []byte("alias123"), + expectedResult: resource.Result{}, + }, } // store a public key for the valid recipient - err = store.WriteEntry(ctx, "0711223344", common.DATA_PUBLIC_KEY, []byte(publicKey)) + err = store.WriteEntry(ctx, "+254711223344", common.DATA_PUBLIC_KEY, []byte(publicKey)) if err != nil { t.Fatal(err) } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + mockAccountService := new(mocks.MockAccountService) // Create the Handlers instance h := &Handlers{ - flagManager: fm.parser, - userdataStore: store, + flagManager: fm.parser, + userdataStore: store, + accountService: mockAccountService, } + aliasResponse := &dataserviceapi.AliasAddress{ + Address: "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9", + } + + mockAccountService.On("CheckAliasAddress", string(tt.input)).Return(aliasResponse, nil) + // Call the method res, err := h.ValidateRecipient(ctx, "validate_recepient", tt.input)