Skip to content

Create polished demo videos without editing skills. Mac/Windows/Linux

862 B
Raw Blame
import { expect, it } from "vitest";
import type { User } from "@supabase/supabase-js";
import { getAccountProfile } from "./account-avatar";
it("uses OAuth profile photos and falls back to name or email initials", () => {
	const user = {
		email: "[email protected]",
		user_metadata: { full_name: "Alex Smith", avatar_url: "https://example.com/photo.jpg" },
	} as User;
	expect(getAccountProfile(user)).toEqual({
		name: "Alex Smith",
		initials: "AS",
		picture: "https://example.com/photo.jpg",
	});
	expect(
		getAccountProfile({ ...user, user_metadata: { picture: "https://example.com/google.jpg" } })
			.picture,
	).toBe("https://example.com/google.jpg");
	expect(getAccountProfile({ ...user, user_metadata: {} })).toEqual({
		name: "[email protected]",
		initials: "A",
		picture: undefined,
	});
	expect(getAccountProfile(null).initials).toBe("LP");
});