package userclient

import (
	"encoding/json"
	"strings"
	"testing"
)

func TestAgencyJSONKeepsSnowflakeIDsAsStrings(t *testing.T) {
	agency := Agency{
		AgencyID:        321170072154411009,
		OwnerUserID:     316033326332776448,
		ParentBDUserID:  320470609978986496,
		CreatedByUserID: 320470609978986496,
	}

	payload, err := json.Marshal(agency)
	if err != nil {
		t.Fatalf("marshal agency: %v", err)
	}
	body := string(payload)

	// 后台前端运行在浏览器里，雪花 ID 超过 JavaScript 安全整数上限；这里必须以字符串返回，避免 321170072154411009 被解析成 321170072154411000 后再提交给删除接口。
	for _, want := range []string{
		`"agencyId":"321170072154411009"`,
		`"ownerUserId":"316033326332776448"`,
		`"parentBdUserId":"320470609978986496"`,
		`"createdByUserId":"320470609978986496"`,
	} {
		if !strings.Contains(body, want) {
			t.Fatalf("agency json should contain %s, got %s", want, body)
		}
	}
}
