Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/serhalp/npm.report. Audit, visualize, share, and track your npm org's trust signals. npm.report
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import { render, screen } from "@testing-library/svelte";import { describe, expect, test, vi } from "vitest";import ExternalView from "./ExternalView.svelte";
describe("ExternalView", () => { test("renders the empty state when every maintainer is a member", () => { render(ExternalView, { props: { report: { rows: [], distinctUsers: 0, byUser: [], scanned: 2 }, onToast: vi.fn<(message: string) => void>(), }, });
expect(screen.getByText("No external maintainers")).toBeInTheDocument(); expect(screen.getAllByText("0")).toHaveLength(2); });
test("renders by-user and detail tables for non-member publish access", () => { render(ExternalView, { props: { report: { distinctUsers: 1, byUser: [{ user: "mallory", count: 2 }], scanned: 2, rows: [ { user: "mallory", pkg: "alpha" }, { user: "mallory", pkg: "beta" }, ], }, onToast: vi.fn<(message: string) => void>(), }, });
expect(screen.getByText("By user — non-members with live publish rights")).toBeInTheDocument(); expect(screen.getByText("Detail — 2 access grants")).toBeInTheDocument(); expect(screen.getAllByText("mallory")).toHaveLength(3); expect(screen.getByText("alpha")).toBeInTheDocument(); expect(screen.getByText("beta")).toBeInTheDocument(); expect( screen.getByRole("table", { name: "External maintainers by npm user" }), ).toBeInTheDocument(); expect( screen.getByRole("table", { name: "External maintainer package access" }), ).toBeInTheDocument(); expect( screen.getByRole("group", { name: "External maintainers by npm user exports" }), ).toBeInTheDocument(); expect( screen.getByRole("group", { name: "External maintainer package access exports" }), ).toBeInTheDocument(); });});