import { renderToStaticMarkup } from "react-dom/server"; import { describe, expect, it } from "vitest"; import { candidateInvitationFixture, contactConsentOffer, } from "../../../entities/invitation/testing"; import { AcceptContactConsentForm } from "./accept-contact-consent-form"; function render(): string { return renderToStaticMarkup( undefined} onFailure={() => undefined} />, ); } describe("accept contact consent form", () => { it("offers each kind the profile holds as a separate, unchecked choice", () => { const html = render(); for (const label of ["ФИО", "Электронная почта", "Телефон"]) { expect(html).toContain(`${label}`); } expect(html).not.toContain("Telegram"); expect(html.match(/type="checkbox"/g)).toHaveLength(4); expect(html).not.toMatch(/checked=""/); }); it("shows the consent text as paragraphs and the organization in the confirmation", () => { const html = render(); expect(html).toContain("

Я согласен передать компании «Северный ветер» отмеченные контакты"); expect(html).toContain("

Согласие относится только к этому приглашению.

"); expect(html).toContain("Я прочитал(а) текст согласия и согласен(на) передать"); }); it("is not ready to send until a kind and the confirmation are chosen", () => { const html = render(); expect(html).toMatch( /]*aria-disabled="true"[^>]*>Принять и передать контакты<\/button>/, ); expect(html).not.toContain('role="alert"'); }); });