A downstream fork of Tranquil PDS for use in margin.cafe margin.cafe
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758import { describe, expect, it } from "vitest";import { getInitialConsentSelections } from "../lib/oauthConsent.ts";
describe("getInitialConsentSelections", () => { it("selects non-restricted permission bundles even when previously denied", () => { expect( getInitialConsentSelections( [], [ { include_scope: "include:app.example.permissions", granted: false, }, ], ), ).toEqual({ "include:app.example.permissions": true }); });
it("omits restricted permission bundles", () => { expect( getInitialConsentSelections( [], [ { include_scope: "include:app.example.restricted", restricted: true, }, ], ), ).toEqual({}); });
it("preserves granted and required initialization for regular scopes", () => { expect( getInitialConsentSelections( [ { scope: "required", required: true, granted: false }, { scope: "granted", required: false, granted: true }, { scope: "denied", required: false, granted: false }, { scope: "new", required: false, granted: null }, { scope: "restricted", required: true, granted: true, restricted: true, }, ], [], ), ).toEqual({ required: true, granted: true, denied: false, new: true, }); });});