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

utils.test.ts

26 lines770 Bytes

1import { describe, expect, it } from "vitest";
2​
3import { deriveAuthClientMetadata } from "./utils.ts";
4​
5describe("deriveAuthClientMetadata", () => {
6 it("labels Electron user agents as Electron instead of Chrome", () => {
7 const metadata = deriveAuthClientMetadata({
8 request: {
9 headers: {
10 "user-agent":
11 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) t3code/0.0.15 Chrome/136.0.7103.93 Electron/36.3.2 Safari/537.36",
12 },
13 source: {
14 remoteAddress: "::ffff:127.0.0.1",
15 },
16 } as never,
17 });
18​
19 expect(metadata).toMatchObject({
20 browser: "Electron",
21 deviceType: "desktop",
22 ipAddress: "127.0.0.1",
23 os: "macOS",
24 });
25 });
26});