- Deleted the layout-store, profiles-store, and index.ts files from the Pinia store setup. - Removed the zod-sync script as it is no longer needed. - Cleaned up the tsconfig.json file by removing unnecessary references. - Updated the login logic in the profiles package to use polling for login results instead of in-process waiters. - Added validation methods for personal data and profile parameters. - Introduced new tests for validation logic in profiles and registration packages. - Enhanced email normalization and validation in the registration package.
37 lines
1.7 KiB
Go
37 lines
1.7 KiB
Go
package profiles
|
|
|
|
import "testing"
|
|
|
|
func TestProfileParamsValidate(t *testing.T) {
|
|
if err := (&ProfileParams{DisplayName: "", AvatarURL: ""}).Validate(); err == nil {
|
|
t.Fatal("Validate() should reject empty display name")
|
|
}
|
|
if err := (&ProfileParams{DisplayName: " Alice ", AvatarURL: "https://example.com/avatar.png"}).Validate(); err != nil {
|
|
t.Fatalf("Validate() returned unexpected error: %v", err)
|
|
}
|
|
}
|
|
|
|
func TestRegisterParamsValidate(t *testing.T) {
|
|
if err := (&RegisterParams{Email: "", DisplayName: "Alice", Password: "validpass"}).Validate(); err == nil {
|
|
t.Fatal("Validate() should reject empty email")
|
|
}
|
|
if err := (&RegisterParams{Email: "alice@example.com", DisplayName: "Alice", Password: "weak"}).Validate(); err == nil {
|
|
t.Fatal("Validate() should reject weak password")
|
|
}
|
|
if err := (&RegisterParams{Email: " Alice@Example.com ", DisplayName: " Alice ", Password: "validpass"}).Validate(); err != nil {
|
|
t.Fatalf("Validate() returned unexpected error: %v", err)
|
|
}
|
|
}
|
|
|
|
func TestPersonalDataParamsValidate(t *testing.T) {
|
|
if err := (&PersonalDataParams{FirstName: "", LastName: "Rossi", Address: "Main 1", Cap: "20100", City: "Milan", Country: "IT"}).Validate(); err == nil {
|
|
t.Fatal("Validate() should reject empty first name")
|
|
}
|
|
if err := (&PersonalDataParams{FirstName: "Mario", LastName: "Rossi", Address: "Main 1", Cap: "20", City: "Milan", Country: "IT"}).Validate(); err == nil {
|
|
t.Fatal("Validate() should reject invalid cap")
|
|
}
|
|
if err := (&PersonalDataParams{FirstName: " Mario ", LastName: " Rossi ", Address: " Main 1 ", Cap: "20100", City: " Milan ", Country: " IT "}).Validate(); err != nil {
|
|
t.Fatalf("Validate() returned unexpected error: %v", err)
|
|
}
|
|
}
|