package types

import (
	"encoding/json"
	"testing"
)

func TestUpdateUserBasicInfoRequestRemarkPresence(t *testing.T) {
	var omitted UpdateUserBasiceInfoRequest
	if err := json.Unmarshal([]byte(`{"user_id":1}`), &omitted); err != nil {
		t.Fatalf("unmarshal omitted remark: %v", err)
	}
	if omitted.Remark != nil {
		t.Fatalf("omitted remark = %q, want nil", *omitted.Remark)
	}

	var cleared UpdateUserBasiceInfoRequest
	if err := json.Unmarshal([]byte(`{"user_id":1,"remark":""}`), &cleared); err != nil {
		t.Fatalf("unmarshal empty remark: %v", err)
	}
	if cleared.Remark == nil {
		t.Fatal("empty remark was decoded as nil, want explicit empty string")
	}
	if *cleared.Remark != "" {
		t.Fatalf("empty remark = %q, want empty string", *cleared.Remark)
	}

	var updated UpdateUserBasiceInfoRequest
	if err := json.Unmarshal([]byte(`{"user_id":1,"remark":"new note"}`), &updated); err != nil {
		t.Fatalf("unmarshal non-empty remark: %v", err)
	}
	if updated.Remark == nil || *updated.Remark != "new note" {
		t.Fatalf("non-empty remark = %#v, want %q", updated.Remark, "new note")
	}
}
