Files
portifolio-evandrodevbr/app/components/contact-subject.test.ts
T
Evandro Fonseca Junior f8545cd442 feat(home): ofertas que vendem o título, WhatsApp no hero e menu do celular acessível
Três ofertas (site que traz pedidos pelo WhatsApp, sistema para tirar a operação da planilha, revisão de sistema existente) com miniatura e formulário com o tipo escolhido; botão principal do hero abre o WhatsApp; moldura da SEV no hero do celular; menu fecha ao navegar, Esc, foco preso incluindo a barra de cookies e espaço para ela; CinematicHome como componente de servidor com ilha cliente; /ia com H1 de oferta e cartão do que você recebe; botão flutuante em aside com transform; AVIF antes de WebP; copy sem repetir contato direto.
2026-10-14 17:01:36 -03:00

59 lines
1.9 KiB
TypeScript

import {
CONTACT_KIND_PARAM,
CONTACT_KINDS,
CONTACT_SUBJECT_OPTIONS,
contactKindHref,
contactSubjectForKind,
DEFAULT_CONTACT_SUBJECT,
} from "./contact-subject";
describe("contact-subject", () => {
it("starts the options with the default, 'Ainda preciso definir', so nobody is pushed into a type", () => {
expect(CONTACT_SUBJECT_OPTIONS[0]).toBe(DEFAULT_CONTACT_SUBJECT);
expect(DEFAULT_CONTACT_SUBJECT).toBe("Ainda preciso definir");
});
it("maps every type an offer asks for to an option of the form", () => {
for (const subject of Object.values(CONTACT_KINDS)) {
expect(CONTACT_SUBJECT_OPTIONS).toContain(subject);
}
expect(CONTACT_KINDS).toEqual({
site: "Site para empresa",
sistema: "Sistemas web sob medida",
revisao: "Revisão ou diagnóstico de sistema",
});
});
it("looks a type up by its own keys only", () => {
expect(contactSubjectForKind("site")).toBe("Site para empresa");
expect(contactSubjectForKind("revisao")).toBe(
"Revisão ou diagnóstico de sistema",
);
for (const unknown of [
"",
"Site",
"constructor",
"toString",
"__proto__",
]) {
expect(contactSubjectForKind(unknown)).toBeUndefined();
}
expect(contactSubjectForKind(null)).toBeUndefined();
expect(contactSubjectForKind(undefined)).toBeUndefined();
});
it("builds the address with the type in the search, before the fragment, so #contact still finds the section", () => {
expect(contactKindHref("site")).toBe(
`/?${CONTACT_KIND_PARAM}=site#contact`,
);
for (const kind of Object.keys(CONTACT_KINDS) as Array<
keyof typeof CONTACT_KINDS
>) {
const url = new URL(contactKindHref(kind), "https://example.com");
expect(url.hash).toBe("#contact");
expect(url.searchParams.get("tipo")).toBe(kind);
expect(url.pathname).toBe("/");
}
});
});