@@ -156,25 +156,37 @@ describe('AuthEffects', () => {
156156
157157 describe ( 'when token is valid' , ( ) => {
158158 it ( 'should return a AUTHENTICATED_SUCCESS action in response to a AUTHENTICATED action' , ( ) => {
159- actions = hot ( '--a-' , { a : { type : AuthActionTypes . AUTHENTICATED , payload : token } } ) ;
159+ actions = hot ( '--a-' , { a : new AuthenticatedAction ( token ) } ) ;
160160
161161 const expected = cold ( '--b-' , { b : new AuthenticatedSuccessAction ( true , token , EPersonMock . _links . self . href ) } ) ;
162162
163163 expect ( authEffects . authenticated$ ) . toBeObservable ( expected ) ;
164164 } ) ;
165165 } ) ;
166166
167- describe ( 'when token is not valid ' , ( ) => {
167+ describe ( 'when token is expired ' , ( ) => {
168168 it ( 'should return a AUTHENTICATED_ERROR action in response to a AUTHENTICATED action' , ( ) => {
169169 spyOn ( ( authEffects as any ) . authService , 'authenticatedUser' ) . and . returnValue ( observableThrow ( new Error ( 'Message Error test' ) ) ) ;
170170
171- actions = hot ( '--a-' , { a : { type : AuthActionTypes . AUTHENTICATED , payload : token } } ) ;
171+ actions = hot ( '--a-' , { a : new AuthenticatedAction ( token ) } ) ;
172172
173173 const expected = cold ( '--b-' , { b : new AuthenticatedErrorAction ( new Error ( 'Message Error test' ) ) } ) ;
174174
175175 expect ( authEffects . authenticated$ ) . toBeObservable ( expected ) ;
176176 } ) ;
177177 } ) ;
178+
179+ describe ( 'when token is not valid but also not expired (~ cookie)' , ( ) => {
180+ it ( 'should return a AUTHENTICATED_ERROR action in response to a AUTHENTICATED action' , ( ) => {
181+ spyOn ( ( authEffects as any ) . authService , 'authenticatedUser' ) . and . returnValue ( observableThrow ( new Error ( 'Message Error test' ) ) ) ;
182+
183+ actions = hot ( '--a-' , { a : new AuthenticatedAction ( token , true ) } ) ;
184+
185+ const expected = cold ( '--b-' , { b : new CheckAuthenticationTokenCookieAction ( ) } ) ;
186+
187+ expect ( authEffects . authenticated$ ) . toBeObservable ( expected ) ;
188+ } ) ;
189+ } ) ;
178190 } ) ;
179191
180192 describe ( 'authenticatedSuccess$' , ( ) => {
@@ -210,7 +222,7 @@ describe('AuthEffects', () => {
210222
211223 actions = hot ( '--a-' , { a : { type : AuthActionTypes . CHECK_AUTHENTICATION_TOKEN } } ) ;
212224
213- const expected = cold ( '--b-' , { b : new AuthenticatedAction ( token ) } ) ;
225+ const expected = cold ( '--b-' , { b : new AuthenticatedAction ( token , true ) } ) ;
214226
215227 expect ( authEffects . checkToken$ ) . toBeObservable ( expected ) ;
216228 } ) ;
0 commit comments