// @ts-nocheck -- run with `bun test`
import { expect, test } from "bun:test";
import { aliquotaIR, simular, SIM_CONFIG, projetarRendaMensal } from "./brasil-urbano-config";

test("taxas por prazo", () => {
  expect(SIM_CONFIG.taxasPorPrazo[12]).toBe(0.016);
  expect(SIM_CONFIG.taxasPorPrazo[24]).toBe(0.018);
  expect(SIM_CONFIG.taxasPorPrazo[36]).toBe(0.02);
});

test("faixas de IR", () => {
  expect(aliquotaIR(6)).toBe(0.225);
  expect(aliquotaIR(12)).toBe(0.2);
  expect(aliquotaIR(24)).toBe(0.175);
  expect(aliquotaIR(36)).toBe(0.15);
});

test("Série 1 bruto 12 meses: juros simples", () => {
  const last = simular(25000, 12, false).at(-1);
  expect(last?.serie1).toBeCloseTo(29800, 2);
});

test("Série 1 líquido 36 meses", () => {
  const last = simular(100000, 36, true).at(-1);
  expect(last?.serie1).toBeCloseTo(100000 + 72000 * 0.85, 2);
});

test("aporte de R$ 25.000 projeta R$ 500 mensais no prazo de 36 meses", () => {
  expect(projetarRendaMensal(25000, 36)).toBe(500);
});

test("aporte de R$ 50.000 projeta R$ 1.000 mensais no prazo de 36 meses", () => {
  expect(projetarRendaMensal(50000, 36)).toBe(1000);
});

test("aporte de R$ 100.000 projeta R$ 2.000 mensais no prazo de 36 meses", () => {
  expect(projetarRendaMensal(100000, 36)).toBe(2000);
});
