package threadsapi

import (
	"encoding/json"
	"testing"
)

func TestTokenExchangeResultUnmarshalNumericUserID(t *testing.T) {
	raw := []byte(`{"access_token":"tok","token_type":"bearer","expires_in":3600,"user_id":123456789}`)
	var result TokenExchangeResult
	if err := json.Unmarshal(raw, &result); err != nil {
		t.Fatalf("unmarshal: %v", err)
	}
	if result.UserID.String() != "123456789" {
		t.Fatalf("user_id = %q, want 123456789", result.UserID.String())
	}
}

func TestUserProfileUnmarshalNumericID(t *testing.T) {
	raw := []byte(`{"id":987654321,"username":"demo","name":"Demo"}`)
	var profile UserProfile
	if err := json.Unmarshal(raw, &profile); err != nil {
		t.Fatalf("unmarshal: %v", err)
	}
	if profile.ID.String() != "987654321" {
		t.Fatalf("id = %q, want 987654321", profile.ID.String())
	}
}
