@@ -659,4 +659,37 @@ describe('AuthManager', () => {
659659 ) ;
660660 } ) ;
661661 } ) ;
662+
663+ describe ( 'getLogoutUrl' , ( ) => {
664+ describe ( 'with a logged in user' , ( ) => {
665+ describe ( 'when a logoutRedirectUri is specified' , ( ) => {
666+ it ( 'should set the endSessionEndpoint `returnTo` and `client_id` query string params' , async ( ) => {
667+ mockGetUser . mockReturnValue ( mockOidcUser ) ;
668+
669+ const am = new AuthManager ( getConfig ( { logoutRedirectUri } ) ) ;
670+ const result = await am . getLogoutUrl ( ) ;
671+ const uri = new URL ( result ) ;
672+
673+ expect ( uri . hostname ) . toEqual ( authenticationDomain ) ;
674+ expect ( uri . pathname ) . toEqual ( logoutEndpoint ) ;
675+ expect ( uri . searchParams . get ( 'client_id' ) ) . toEqual ( clientId ) ;
676+ expect ( uri . searchParams . get ( 'returnTo' ) ) . toEqual ( logoutRedirectUri ) ;
677+ } ) ;
678+ } ) ;
679+
680+ describe ( 'when no post_logout_redirect_uri is specified' , ( ) => {
681+ it ( 'should return the endSessionEndpoint without a `returnTo` or `client_id` query string params' , async ( ) => {
682+ mockGetUser . mockReturnValue ( mockOidcUser ) ;
683+
684+ const am = new AuthManager ( getConfig ( ) ) ;
685+ const result = await am . getLogoutUrl ( ) ;
686+ const uri = new URL ( result ) ;
687+
688+ expect ( uri . hostname ) . toEqual ( authenticationDomain ) ;
689+ expect ( uri . pathname ) . toEqual ( logoutEndpoint ) ;
690+ expect ( uri . searchParams . get ( 'client_id' ) ) . toEqual ( clientId ) ;
691+ } ) ;
692+ } ) ;
693+ } ) ;
694+ } ) ;
662695} ) ;
0 commit comments