summaryrefslogtreecommitdiffstats
path: root/test/server.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/server.js')
-rw-r--r--test/server.js27
1 files changed, 26 insertions, 1 deletions
diff --git a/test/server.js b/test/server.js
index 720f4a0..db31c63 100644
--- a/test/server.js
+++ b/test/server.js
@@ -40,6 +40,26 @@ const ADDRESSES = {
},
};
+/**
+ * The `faixa` a 404 carries when the CEP falls inside a municipality that
+ * simply never received that number. `25845000` is the real Areal/RJ shape —
+ * the `-000` that municipality never got. `25845999` is deliberately broken,
+ * so the tests can prove a malformed `faixa` degrades to the plain message.
+ */
+const FAIXAS = {
+ 25845000: {
+ localidade: "Areal",
+ uf: "RJ",
+ estado: "Rio de Janeiro",
+ regiao: "Sudeste",
+ ibge: "3300225",
+ cep_ini: "25845001",
+ cep_fim: "25849899",
+ ceps: 118,
+ },
+ 25845999: { uf: "RJ", cep_ini: 25845001 },
+};
+
const CORS = {
"Access-Control-Allow-Origin": "*",
"Content-Type": "application/json; charset=utf-8",
@@ -105,8 +125,13 @@ export function startApi() {
}
const address = ADDRESSES[path];
if (!address) {
+ const faixa = FAIXAS[path];
return new Response(
- JSON.stringify({ erro: "cep_nao_encontrado", mensagem: "CEP não existe na base do DNE" }),
+ JSON.stringify({
+ erro: "cep_nao_encontrado",
+ mensagem: "CEP não existe na base do DNE",
+ ...(faixa ? { faixa } : {}),
+ }),
{ status: 404, headers: CORS },
);
}