package types

import "testing"

func TestPatchFromAuthProfileClearsAvatar(t *testing.T) {
	empty := ""
	url := "https://example.com/a.png"
	p1 := PatchFromAuthProfile(&AuthProfilePatchReq{AvatarUrl: &empty})
	if p1.AvatarURL == nil || *p1.AvatarURL != "" {
		t.Fatalf("empty should clear, got %#v", p1.AvatarURL)
	}
	p2 := PatchFromAuthProfile(&AuthProfilePatchReq{AvatarUrl: &url})
	if p2.AvatarURL == nil || *p2.AvatarURL != url {
		t.Fatalf("set url, got %#v", p2.AvatarURL)
	}
	p3 := PatchFromAuthProfile(&AuthProfilePatchReq{DisplayName: "x"})
	if p3.AvatarURL != nil {
		t.Fatalf("omit should leave nil, got %#v", p3.AvatarURL)
	}
}
