File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed
Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -150,7 +150,7 @@ const renderAuthHook = async () => {
150150
151151describe ( 'useYVAuth' , ( ) => {
152152 beforeEach ( ( ) => {
153- vi . clearAllMocks ( ) ;
153+ vi . resetAllMocks ( ) ;
154154
155155 // Setup window mock
156156 vi . stubGlobal ( 'window' , mockWindow ) ;
@@ -248,6 +248,30 @@ describe('useYVAuth', () => {
248248 } ) ,
249249 ) . rejects . toThrow ( 'Sign in failed' ) ;
250250 } ) ;
251+
252+ it ( 'should use redirectUri from provider when redirectUrl is not passed' , async ( ) => {
253+ const { result } = await renderAuthHook ( ) ;
254+
255+ await act ( async ( ) => {
256+ await result . current . signIn ( ) ;
257+ } ) ;
258+
259+ expect ( vi . mocked ( YouVersionAPIUsers . signIn ) ) . toHaveBeenCalledWith ( 'http://test.example.com' ) ;
260+ } ) ;
261+
262+ it ( 'should use redirectUri from provider with scopes when redirectUrl is not passed' , async ( ) => {
263+ const { result } = await renderAuthHook ( ) ;
264+ const scopes : AuthenticationScopes [ ] = [ 'profile' , 'email' ] ;
265+
266+ await act ( async ( ) => {
267+ await result . current . signIn ( { scopes } ) ;
268+ } ) ;
269+
270+ expect ( vi . mocked ( YouVersionAPIUsers . signIn ) ) . toHaveBeenCalledWith (
271+ 'http://test.example.com' ,
272+ scopes ,
273+ ) ;
274+ } ) ;
251275 } ) ;
252276
253277 describe ( 'processCallback' , ( ) => {
You can’t perform that action at this time.
0 commit comments