File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed
__tests__/providers/cognito Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,23 @@ describe('fetchDevices', () => {
8181 } ) ;
8282
8383 it ( 'should fetch devices and parse client response correctly' , async ( ) => {
84- expect ( await fetchDevices ( ) ) . toEqual ( [ apiOutputDevice ] ) ;
84+ const {
85+ id,
86+ name,
87+ attributes,
88+ createDate,
89+ lastAuthenticatedDate,
90+ lastModifiedDate,
91+ } = ( await fetchDevices ( ) ) [ 0 ] ;
92+ expect ( id ) . toEqual ( apiOutputDevice . id ) ;
93+ expect ( name ) . toEqual ( apiOutputDevice . name ) ;
94+ expect ( attributes ) . toEqual ( apiOutputDevice . attributes ) ;
95+ expect ( createDate ) . toEqual ( apiOutputDevice . createDate ) ;
96+ expect ( lastAuthenticatedDate ) . toEqual (
97+ apiOutputDevice . lastAuthenticatedDate ,
98+ ) ;
99+ expect ( lastModifiedDate ) . toEqual ( apiOutputDevice . lastModifiedDate ) ;
100+
85101 expect ( mockListDevices ) . toHaveBeenCalledWith (
86102 expect . objectContaining ( { region : 'us-west-2' } ) ,
87103 expect . objectContaining ( {
Original file line number Diff line number Diff line change 77 assertTokenProviderConfig ,
88} from '@aws-amplify/core/internals/utils' ;
99
10- import { FetchDevicesOutput } from '../types' ;
10+ import { AWSAuthDevice , FetchDevicesOutput } from '../types' ;
1111import { DeviceType } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider/types' ;
1212import { assertAuthTokens } from '../utils/types' ;
1313import { getRegionFromUserPoolId } from '../../../foundation/parsers' ;
@@ -77,7 +77,7 @@ const parseDevicesResponse = async (
7777 { } ,
7878 ) ;
7979
80- return {
80+ const result : AWSAuthDevice = {
8181 id,
8282 name : deviceName ,
8383 attributes,
@@ -91,6 +91,8 @@ const parseDevicesResponse = async (
9191 ? new Date ( DeviceLastAuthenticatedDate * 1000 )
9292 : undefined ,
9393 } ;
94+
95+ return result ;
9496 } ,
9597 ) ;
9698} ;
Original file line number Diff line number Diff line change @@ -332,4 +332,5 @@ export interface AWSAuthUser {
332332 */
333333export interface AuthDevice {
334334 id : string ;
335+ name ?: string ;
335336}
You can’t perform that action at this time.
0 commit comments