Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

telemetryId.test.ts

19 lines776 Bytes

1import { describe, expect, it } from "vite-plus/test";
2​
3import { hashTelemetryId, isTelemetryIdHash } from "./telemetryId.ts";
4​
5describe("telemetry ids", () => {
6 // The server hashes the linked Connect account and clients hash the signed-in
7 // one. Both must give plain SHA-256 hex, or the two never match.
8 it("is the SHA-256 hex digest of the id", () => {
9 expect(hashTelemetryId("user_connect")).toBe(
10 "7938265611170ce1ba814a67f5a51bcff2b9b46c5597da465e6f098f2217717a",
11 );
12 });
13​
14 it("accepts only hashes, never a raw id", () => {
15 expect(isTelemetryIdHash(hashTelemetryId("user_connect"))).toBe(true);
16 expect(isTelemetryIdHash("user_connect")).toBe(false);
17 expect(isTelemetryIdHash(hashTelemetryId("x").toUpperCase())).toBe(false);
18 });
19});