import { 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, }); }); });