Revamp calendar dialog (#158)
Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
import { getCalendarVisibility } from "../../src/components/Calendar/utils/calendarUtils";
|
||||
|
||||
interface AclEntry {
|
||||
privilege: string;
|
||||
principal: string;
|
||||
protected: boolean;
|
||||
}
|
||||
|
||||
describe("getCalendarVisibility", () => {
|
||||
it("returns 'public' when {DAV:}authenticated has {DAV:}read", () => {
|
||||
const acl: AclEntry[] = [
|
||||
{
|
||||
privilege: "{DAV:}read",
|
||||
principal: "{DAV:}authenticated",
|
||||
protected: true,
|
||||
},
|
||||
];
|
||||
expect(getCalendarVisibility(acl)).toBe("public");
|
||||
});
|
||||
|
||||
it("returns 'private' when {DAV:}authenticated only has read-free-busy", () => {
|
||||
const acl: AclEntry[] = [
|
||||
{
|
||||
privilege: "{urn:ietf:params:xml:ns:caldav}read-free-busy",
|
||||
principal: "{DAV:}authenticated",
|
||||
protected: true,
|
||||
},
|
||||
];
|
||||
expect(getCalendarVisibility(acl)).toBe("private");
|
||||
});
|
||||
|
||||
it("returns 'private' when {DAV:}authenticated is not present", () => {
|
||||
const acl: AclEntry[] = [
|
||||
{
|
||||
privilege: "{DAV:}read",
|
||||
principal: "principals/users/123",
|
||||
protected: true,
|
||||
},
|
||||
];
|
||||
expect(getCalendarVisibility(acl)).toBe("private");
|
||||
});
|
||||
|
||||
it("ignores non-authenticated principals and still returns 'private'", () => {
|
||||
const acl: AclEntry[] = [
|
||||
{
|
||||
privilege: "{DAV:}read",
|
||||
principal: "principals/users/other",
|
||||
protected: true,
|
||||
},
|
||||
{
|
||||
privilege: "{DAV:}write",
|
||||
principal: "principals/users/other",
|
||||
protected: true,
|
||||
},
|
||||
];
|
||||
expect(getCalendarVisibility(acl)).toBe("private");
|
||||
});
|
||||
|
||||
it("stops early when it finds a {DAV:}read for {DAV:}authenticated", () => {
|
||||
const acl: AclEntry[] = [
|
||||
{
|
||||
privilege: "{DAV:}read",
|
||||
principal: "{DAV:}authenticated",
|
||||
protected: true,
|
||||
},
|
||||
{
|
||||
privilege: "{DAV:}write",
|
||||
principal: "{DAV:}authenticated",
|
||||
protected: true,
|
||||
},
|
||||
];
|
||||
expect(getCalendarVisibility(acl)).toBe("public");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user