import { TestBed } from '@angular/core/testing';
import { ICellRendererParams } from 'ag-grid-community';
import { AmountCellRenderer } from './amount-cell-renderer';
import { TeamActivity } from '../../models/transaction.model';

describe('AmountCellRenderer', () => {
  function create(activity: TeamActivity) {
    const fixture = TestBed.createComponent(AmountCellRenderer);
    fixture.componentInstance.agInit({
      data: activity,
    } as unknown as ICellRendererParams<TeamActivity>);
    fixture.detectChanges();
    return fixture;
  }

  it('renders an inflow amount for a payment', () => {
    const fixture = create({
      id: 1,
      date: '2026-07-01',
      amount: 12,
      type: 'payment',
      isTeamWalletTransaction: false,
    });

    const el = fixture.nativeElement.querySelector('[data-testid="transaction-amount"]');
    expect(el.classList).toContain('inflow');
  });

  it('renders a neutral amount for a fine (no real cash flow)', () => {
    const fixture = create({
      id: 2,
      date: '2026-07-01',
      amount: 5,
      type: 'fine',
      isTeamWalletTransaction: false,
    });

    const el = fixture.nativeElement.querySelector('[data-testid="transaction-amount"]');
    expect(el.classList).toContain('neutral');
  });
});
