31 lines
902 B
TypeScript
31 lines
902 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { isRepUser } from "./rep-visibility";
|
|
|
|
describe("isRepUser", () => {
|
|
it("returns true when user_type includes REP", () => {
|
|
expect(isRepUser(["REP"])).toBe(true);
|
|
});
|
|
|
|
it("is case-insensitive", () => {
|
|
expect(isRepUser(["rep"])).toBe(true);
|
|
});
|
|
|
|
it("returns true when REP is combined with other roles", () => {
|
|
expect(isRepUser(["BUYER", "REP"])).toBe(true);
|
|
});
|
|
|
|
it("returns false for other roles", () => {
|
|
expect(isRepUser(["BUYER"])).toBe(false);
|
|
expect(isRepUser(["ADMIN", "QUOTER"])).toBe(false);
|
|
});
|
|
|
|
it("returns false for null, undefined, or non-array input", () => {
|
|
expect(isRepUser(null)).toBe(false);
|
|
expect(isRepUser(undefined)).toBe(false);
|
|
expect(isRepUser("REP")).toBe(false);
|
|
});
|
|
|
|
it("returns false for an empty array", () => {
|
|
expect(isRepUser([])).toBe(false);
|
|
});
|
|
});
|