mirror of
https://github.com/block/buzz.git
synced 2026-11-27 11:41:21 +00:00
Signed-off-by: Wes <wesbillman@users.noreply.github.com> Co-authored-by: Pinky <44b8e82baa6e0e254e0208d68f335c283c94e7b78dd1fa10d5a49d3f13dd0435@sprout-oss.stage.blox.sqprod.co>
73 lines
2.2 KiB
JavaScript
73 lines
2.2 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { describe, it } from "node:test";
|
|
|
|
import { communityRailIndicators } from "./CommunityRail.tsx";
|
|
|
|
describe("communityRailIndicators", () => {
|
|
it("shows no badge for an observed community with unread but no mentions", () => {
|
|
const r = communityRailIndicators({ hasUnread: true, state: "ready" });
|
|
assert.equal(r.showBadge, false);
|
|
assert.equal(r.showDot, true);
|
|
assert.equal(r.pending, false);
|
|
});
|
|
|
|
it("shows no badge and no dot for an observed community with no unread", () => {
|
|
const r = communityRailIndicators({ hasUnread: false, state: "ready" });
|
|
assert.equal(r.showBadge, false);
|
|
assert.equal(r.showDot, false);
|
|
assert.equal(r.pending, false);
|
|
});
|
|
|
|
it("shows a mention badge with the count when mentions are present — no dot", () => {
|
|
const r = communityRailIndicators({
|
|
hasUnread: true,
|
|
count: 3,
|
|
state: "ready",
|
|
});
|
|
assert.equal(r.showBadge, true);
|
|
assert.equal(r.showDot, false);
|
|
assert.equal(r.mentionCount, 3);
|
|
assert.equal(r.badgeLabel, "3");
|
|
});
|
|
|
|
it("caps the badge label at 99+", () => {
|
|
const r = communityRailIndicators({
|
|
hasUnread: true,
|
|
count: 250,
|
|
state: "ready",
|
|
});
|
|
assert.equal(r.badgeLabel, "99+");
|
|
});
|
|
|
|
it("never reports mentions or dot for an unobserved (unknown) community", () => {
|
|
const r = communityRailIndicators({
|
|
hasUnread: true,
|
|
count: 5,
|
|
state: "unknown",
|
|
});
|
|
assert.equal(r.showBadge, false);
|
|
assert.equal(r.showDot, false);
|
|
assert.equal(r.mentionCount, 0);
|
|
assert.equal(r.pending, true);
|
|
});
|
|
|
|
it("treats loading as pending — no badge, no dot", () => {
|
|
const r = communityRailIndicators({ hasUnread: false, state: "loading" });
|
|
assert.equal(r.pending, true);
|
|
assert.equal(r.showBadge, false);
|
|
assert.equal(r.showDot, false);
|
|
});
|
|
|
|
it("never reports mentions or dot on an errored observation", () => {
|
|
const r = communityRailIndicators({
|
|
hasUnread: true,
|
|
count: 2,
|
|
state: "error",
|
|
});
|
|
assert.equal(r.showBadge, false);
|
|
assert.equal(r.showDot, false);
|
|
assert.equal(r.mentionCount, 0);
|
|
assert.equal(r.pending, false);
|
|
});
|
|
});
|