import { describe, it, expect } from 'vitest';
import { PlatformFee } from '../value-objects/platform-fee.vo';

describe('PlatformFee', () => {
  it('should calculate 5% fee from order amount', () => {
    const result = PlatformFee.fromOrderAmount(10_000_000n);
    expect(result.isOk).toBe(true);
    expect(result.unwrap().value).toBe(500_000n);
  });

  it('should calculate fee for large amounts', () => {
    const result = PlatformFee.fromOrderAmount(5_000_000_000n);
    expect(result.isOk).toBe(true);
    expect(result.unwrap().value).toBe(250_000_000n);
  });

  it('should reject zero order amount', () => {
    const result = PlatformFee.fromOrderAmount(0n);
    expect(result.isErr).toBe(true);
  });

  it('should reject negative order amount', () => {
    const result = PlatformFee.fromOrderAmount(-100n);
    expect(result.isErr).toBe(true);
  });

  it('should create explicit fee', () => {
    const result = PlatformFee.create(100_000n);
    expect(result.isOk).toBe(true);
    expect(result.unwrap().value).toBe(100_000n);
  });

  it('should allow zero explicit fee', () => {
    const result = PlatformFee.create(0n);
    expect(result.isOk).toBe(true);
    expect(result.unwrap().value).toBe(0n);
  });

  it('should reject negative explicit fee', () => {
    const result = PlatformFee.create(-1n);
    expect(result.isErr).toBe(true);
  });
});
