51 lines
1.9 KiB
TypeScript
51 lines
1.9 KiB
TypeScript
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(
|
|
<AcceptContactConsentForm
|
|
invitation={candidateInvitationFixture()}
|
|
offer={contactConsentOffer}
|
|
organizationName="Северный ветер"
|
|
csrfToken={"A".repeat(43)}
|
|
onAccepted={() => 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(`<span>${label}</span>`);
|
|
}
|
|
expect(html).not.toContain("<span>Telegram</span>");
|
|
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("<p>Я согласен передать компании «Северный ветер» отмеченные контакты");
|
|
expect(html).toContain("<p>Согласие относится только к этому приглашению.</p>");
|
|
expect(html).toContain("Я прочитал(а) текст согласия и согласен(на) передать");
|
|
});
|
|
|
|
it("is not ready to send until a kind and the confirmation are chosen", () => {
|
|
const html = render();
|
|
|
|
expect(html).toMatch(
|
|
/<button[^>]*aria-disabled="true"[^>]*>Принять и передать контакты<\/button>/,
|
|
);
|
|
expect(html).not.toContain('role="alert"');
|
|
});
|
|
});
|