@@ -161,25 +161,37 @@ describe('AuthEffects', () => {
161161
162162 describe ( 'when token is valid' , ( ) => {
163163 it ( 'should return a AUTHENTICATED_SUCCESS action in response to a AUTHENTICATED action' , ( ) => {
164- actions = hot ( '--a-' , { a : { type : AuthActionTypes . AUTHENTICATED , payload : token } } ) ;
164+ actions = hot ( '--a-' , { a : new AuthenticatedAction ( token ) } ) ;
165165
166166 const expected = cold ( '--b-' , { b : new AuthenticatedSuccessAction ( true , token , EPersonMock . _links . self . href ) } ) ;
167167
168168 expect ( authEffects . authenticated$ ) . toBeObservable ( expected ) ;
169169 } ) ;
170170 } ) ;
171171
172- describe ( 'when token is not valid ' , ( ) => {
172+ describe ( 'when token is expired ' , ( ) => {
173173 it ( 'should return a AUTHENTICATED_ERROR action in response to a AUTHENTICATED action' , ( ) => {
174174 spyOn ( ( authEffects as any ) . authService , 'authenticatedUser' ) . and . returnValue ( observableThrow ( new Error ( 'Message Error test' ) ) ) ;
175175
176- actions = hot ( '--a-' , { a : { type : AuthActionTypes . AUTHENTICATED , payload : token } } ) ;
176+ actions = hot ( '--a-' , { a : new AuthenticatedAction ( token ) } ) ;
177177
178178 const expected = cold ( '--b-' , { b : new AuthenticatedErrorAction ( new Error ( 'Message Error test' ) ) } ) ;
179179
180180 expect ( authEffects . authenticated$ ) . toBeObservable ( expected ) ;
181181 } ) ;
182182 } ) ;
183+
184+ describe ( 'when token is not valid but also not expired (~ cookie)' , ( ) => {
185+ it ( 'should return a AUTHENTICATED_ERROR action in response to a AUTHENTICATED action' , ( ) => {
186+ spyOn ( ( authEffects as any ) . authService , 'authenticatedUser' ) . and . returnValue ( observableThrow ( new Error ( 'Message Error test' ) ) ) ;
187+
188+ actions = hot ( '--a-' , { a : new AuthenticatedAction ( token , true ) } ) ;
189+
190+ const expected = cold ( '--b-' , { b : new CheckAuthenticationTokenCookieAction ( ) } ) ;
191+
192+ expect ( authEffects . authenticated$ ) . toBeObservable ( expected ) ;
193+ } ) ;
194+ } ) ;
183195 } ) ;
184196
185197 describe ( 'authenticatedSuccess$' , ( ) => {
@@ -215,7 +227,7 @@ describe('AuthEffects', () => {
215227
216228 actions = hot ( '--a-' , { a : { type : AuthActionTypes . CHECK_AUTHENTICATION_TOKEN } } ) ;
217229
218- const expected = cold ( '--b-' , { b : new AuthenticatedAction ( token ) } ) ;
230+ const expected = cold ( '--b-' , { b : new AuthenticatedAction ( token , true ) } ) ;
219231
220232 expect ( authEffects . checkToken$ ) . toBeObservable ( expected ) ;
221233 } ) ;
0 commit comments