Skip to content

test(b3): accept empty fund lists for FIAGRO-FIDC and FIA - #824

Closed
mateussiqueira wants to merge 2 commits into
BrasilAPI:mainfrom
mateussiqueira:fix/b3-empty-lists
Closed

mateussiqueira wants to merge 2 commits into
BrasilAPI:mainfrom
mateussiqueira:fix/b3-empty-lists

Conversation

@mateussiqueira

Copy link
Copy Markdown
Contributor

Problema

Os testes de fundos B3 para FIAGRO-FIDC e FIA usam expect.arrayContaining, que exige pelo menos um item. Porém a B3 pode legitimamente retornar [] para esses tipos.

Reprodução

curl https://brasilapi.com.br/api/tickers/b3/fundos/v1/FIAGRO-FIDC
# → []  (válido, mas teste falha)
npm test
# → FAIL Lista tickers de fundos tipo FIAGRO-FIDC
# → FAIL Lista tickers de fundos tipo FIA

Solução

Extrai um helper expectValidFundListOrEmpty que valida o array e, se não vazio, aplica o schema normalmente.

Closes #800

B3 legitimately returns empty arrays for FIAGRO-FIDC and FIA fund
types when no tickers are listed. The tests used
expect.arrayContaining which requires at least one element.

Replace with expectValidFundListOrEmpty helper that validates
the array structure and only checks schema when items exist.

Fixes BrasilAPI#800
@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

Deployment failed with the following error:

The `vercel.json` schema validation failed with the following message: should NOT have additional property `public`

Learn More: https://vercel.com/docs/concepts/projects/project-configuration

@vercel

vercel Bot commented Jun 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
brasilapi Error Error Jun 22, 2026 7:01pm

Request Review

The parseObject function expected tipo_ato_ini / numero_ato_ini /
ano_ato_ini (old upstream format), but the Siscomex API changed to
tipo_ato / numero_ato / ano_ato. The fallback ncmList.json also
uses the new format.

When the upstream rate limit (3 req/h) was hit, the fallback
produced undefined values because the destructured _ini fields
didn't exist, causing tipo_ato / numero_ato / ano_ato to be
omitted from the response.

Fix: destructure both naming conventions, preferring the new
format with nullish coalescing (??) as fallback.

Fixes BrasilAPI#796
@sonarqubecloud

Copy link
Copy Markdown

@lucianopf

Copy link
Copy Markdown
Member

Oi @mateussiqueira! Obrigado pela contribuição! 🙏

Esse PR mistura duas correções que estão sendo tratadas separadamente:

Fechando este PR em favor do #822 + #825. Se discordar, comenta aqui que a gente reavalia! 💪

This branch had an error being deployed

1 failed deployment
Preview — 6c8cf2ab Deployed Jun 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[B3] Testes de fundos FIAGRO-FIDC e FIA falham quando não há tickers listados

2 participants