File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,3 +11,29 @@ describe('ensureLoggedIn', () => {
1111 expect ( testLogin . ensureLoggedIn ( { } ) ) . toBeInstanceOf ( Object )
1212 } )
1313} )
14+
15+ describe ( 'getUserRoles' , ( ) => {
16+ afterEach ( ( ) => {
17+ jest . restoreAllMocks ( )
18+ jest . resetModules ( )
19+ } )
20+
21+ it ( 'returns [] and does not load preferences when current user is missing' , async ( ) => {
22+ const solidLogic = require ( 'solid-logic' )
23+
24+ const currentUserSpy = jest
25+ . spyOn ( solidLogic . authn , 'currentUser' )
26+ . mockReturnValue ( null )
27+ const loadPreferencesSpy = jest . spyOn (
28+ solidLogic . solidLogicSingleton . profile ,
29+ 'loadPreferences'
30+ )
31+
32+ const loginModule = require ( '../../../src/login/login' )
33+ const roles = await loginModule . getUserRoles ( )
34+
35+ expect ( currentUserSpy ) . toHaveBeenCalled ( )
36+ expect ( roles ) . toEqual ( [ ] )
37+ expect ( loadPreferencesSpy ) . not . toHaveBeenCalled ( )
38+ } )
39+ } )
You can’t perform that action at this time.
0 commit comments