Files
calendar/packages/features/auth/signup/utils/getOrgUsernameFromEmail.test.ts
T
Hariom BalharaandGitHub ac8b4a2861 fix: Wrong username with -{DOMAIN} in case of an autoAcceptEmail when synced through SCIM (#18384)
* Okta fixes

* Fix username and name in case of sync from Okta

* Fix username and name in case of sync from Okta

* Add test

* cleanup code and add tests
2025-01-29 12:05:27 -03:00

28 lines
1.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { getOrgUsernameFromEmail, deriveNameFromOrgUsername } from "./getOrgUsernameFromEmail";
describe("getOrgUsernameFromEmail", () => {
it("should generate username with only email user part when domain matches autoAcceptEmailDomain", () => {
const email = "john.doe@example.com";
const autoAcceptEmailDomain = "example.com";
const result = getOrgUsernameFromEmail(email, autoAcceptEmailDomain);
expect(result).toBe("john.doe");
});
it("should generate username with email user and domain when domain doesn't match autoAcceptEmailDomain", () => {
const email = "john.doe@example.com";
const autoAcceptEmailDomain = "different.com";
const result = getOrgUsernameFromEmail(email, autoAcceptEmailDomain);
expect(result).toBe("john.doe-example");
});
});
describe("deriveNameFromOrgUsername", () => {
it("should convert hyphenated username to capitalized words", () => {
const username = "john-doe-example";
const result = deriveNameFromOrgUsername({ username });
expect(result).toBe("John Doe Example");
});
});