Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

1.8 KB
Raw Blame
import assert from "node:assert/strict";
import { test } from "vitest";
import { contributorAvatarUrl, contributorsFromActivity, dedupeContributors, type Contributor } from "./contributors";

const contributor = (login: string): Contributor => ({
  login,
  avatar_url: `https://avatars.githubusercontent.com/${login}`,
  html_url: `https://github.com/${login}`,
  contributions: 1,
});

test("dedupeContributors removes duplicate GitHub logins case-insensitively", () => {
  const first = contributor("BlueSkyXN");

  assert.deepEqual(dedupeContributors([first, contributor("blueskyxn"), contributor("other")]), [first, contributor("other")]);
});

test("dedupeContributors preserves the original contributor order", () => {
  const contributors = [contributor("first"), contributor("second"), contributor("third")];

  assert.deepEqual(dedupeContributors(contributors), contributors);
});

test("contributorsFromActivity strips snapshot-only fields from landing data", () => {
  assert.deepEqual(
    contributorsFromActivity([
      {
        login: "builder",
        avatarUrl: "https://avatars.githubusercontent.com/u/1",
        profileUrl: "https://github.com/builder",
        commits: 42,
        mergedPullRequests: 7,
        firstContributionAt: "2026-01-01T00:00:00Z",
        latestContributionAt: "2026-07-01T00:00:00Z",
      },
    ]),
    [
      {
        login: "builder",
        avatar_url: "https://avatars.githubusercontent.com/u/1",
        html_url: "https://github.com/builder",
        contributions: 42,
      },
    ],
  );
});

test("contributorAvatarUrl requests small GitHub avatars and preserves local images", () => {
  assert.equal(contributorAvatarUrl("https://avatars.githubusercontent.com/u/1?v=4"), "https://avatars.githubusercontent.com/u/1?v=4&s=64");
  assert.equal(contributorAvatarUrl("/avatars/contributor.png"), "/avatars/contributor.png");
});