import { describe, test, expect } from "bun:test";
import { genImplicitPerm } from "../../src/modules/permission-utils/genImplicitPerm";

describe("genImplicitPerm", () => {
  test("builds a dot-delimited implicit permission string", () => {
    const result = genImplicitPerm("sessions", "sess-1", "user-1");
    expect(result).toBe("resource.sessions.sess-1.user.user-1.implicit");
  });

  test("works with different resource types", () => {
    const result = genImplicitPerm("roles", "role-abc", "user-xyz");
    expect(result).toBe("resource.roles.role-abc.user.user-xyz.implicit");
  });

  test("handles IDs with special characters", () => {
    const result = genImplicitPerm("keys", "key-123_abc", "u-1");
    expect(result).toBe("resource.keys.key-123_abc.user.u-1.implicit");
  });
});
