71 lines
2.5 KiB
TypeScript
71 lines
2.5 KiB
TypeScript
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
import { renderToString } from "react-dom/server";
|
|
import { describe, expect, it } from "vitest";
|
|
import type { AnonymousCardContent } from "../../../shared/api/schemas";
|
|
import { matchCardQueryKeys } from "../api/card";
|
|
import { CandidateCardDetails } from "./candidate-card-details";
|
|
|
|
const accountId = "11111111-1111-4111-8111-111111111111";
|
|
const organizationId = "22222222-2222-4222-8222-222222222222";
|
|
const handle = "cv1_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
|
|
|
|
const card: AnonymousCardContent = {
|
|
pseudonym: handle,
|
|
categories: null,
|
|
stack: ["go"],
|
|
self_assessment: null,
|
|
experience_band: "3_6",
|
|
work_formats: null,
|
|
salary_compatibility: null,
|
|
projects: [
|
|
{
|
|
title: "Платежный шлюз",
|
|
description: "Проводки и сверки.\nВыплаты по расписанию.",
|
|
stack: ["Go", "PostgreSQL"],
|
|
repository_verified: true,
|
|
},
|
|
{ title: "Каталог", description: null, stack: [], repository_verified: false },
|
|
],
|
|
};
|
|
|
|
function render(content: AnonymousCardContent): string {
|
|
const client = new QueryClient();
|
|
client.setQueryData(matchCardQueryKeys.card(accountId, organizationId, handle), content);
|
|
return renderToString(
|
|
<QueryClientProvider client={client}>
|
|
<CandidateCardDetails
|
|
id="card-panel"
|
|
accountId={accountId}
|
|
organizationId={organizationId}
|
|
candidateHandle={handle}
|
|
open
|
|
/>
|
|
</QueryClientProvider>,
|
|
).replaceAll("<!-- -->", "");
|
|
}
|
|
|
|
describe("candidate card details", () => {
|
|
it("lists the published projects with tags and a badge for a verified repository", () => {
|
|
const html = render(card);
|
|
|
|
expect(html).toContain(">Проекты</h6>");
|
|
expect(html).toContain("Платежный шлюз");
|
|
expect(html).toContain("Выплаты по расписанию.");
|
|
expect(html).toContain(">PostgreSQL<");
|
|
expect(html.match(/Подтвержден публичным репозиторием/g)).toHaveLength(1);
|
|
expect(html).toContain("Каталог");
|
|
});
|
|
|
|
it("shows no address or link of a repository", () => {
|
|
const html = render(card);
|
|
|
|
expect(html).not.toContain("github");
|
|
expect(html).not.toMatch(/href="https?:/);
|
|
});
|
|
|
|
it("shows no projects block while the card carries none", () => {
|
|
expect(render({ ...card, projects: null })).not.toContain(">Проекты</h6>");
|
|
expect(render({ ...card, projects: [] })).not.toContain(">Проекты</h6>");
|
|
});
|
|
});
|