package order

import (
	"testing"
	"time"

	"hfb_sys/backend/internal/model"
)

func TestOrderDTOForUserHidesDepositHoldFields(t *testing.T) {
	now := time.Now()
	row := orderRow{
		RentalOrder: model.RentalOrder{
			ID:                    1,
			OwnerID:               10,
			RenterID:              20,
			DepositHoldStatus:     model.DepositHoldStatusHeld,
			DepositHoldAmountCent: 1000,
			DepositHoldReason:     "风控复核",
			DepositHeldAt:         &now,
			DepositHoldReleasedAt: &now,
		},
	}

	dto := row.toDTOForUser(20)
	if dto.DepositHoldStatus != "" {
		t.Fatalf("deposit hold status = %q, want empty", dto.DepositHoldStatus)
	}
	if dto.DepositHoldAmountCent != 0 {
		t.Fatalf("deposit hold amount = %d, want 0", dto.DepositHoldAmountCent)
	}
	if dto.DepositHoldReason != "" {
		t.Fatalf("deposit hold reason = %q, want empty", dto.DepositHoldReason)
	}
	if dto.DepositHeldAt != nil {
		t.Fatalf("deposit held at = %v, want nil", dto.DepositHeldAt)
	}
	if dto.DepositHoldReleasedAt != nil {
		t.Fatalf("deposit hold released at = %v, want nil", dto.DepositHoldReleasedAt)
	}
}
