@@ -2,10 +2,9 @@ import '@testing-library/jest-dom/extend-expect';
22import React from 'react' ;
33import withAuthenticationRequired from '../src/with-authentication-required' ;
44import { render , screen , waitFor } from '@testing-library/react' ;
5- import { Auth0Client } from '@auth0/auth0-spa-js' ;
5+ import { Auth0Client , User } from '@auth0/auth0-spa-js' ;
66import Auth0Provider from '../src/auth0-provider' ;
77import { mocked } from 'ts-jest/utils' ;
8- import { User } from '../src/auth-state' ;
98
109const mockClient = mocked ( new Auth0Client ( { client_id : '' , domain : '' } ) ) ;
1110
@@ -43,8 +42,8 @@ describe('withAuthenticationRequired', () => {
4342 it ( 'should not allow access to claims-restricted components' , async ( ) => {
4443 const MyComponent = ( ) : JSX . Element => < > Private</ > ;
4544 const WrappedComponent = withAuthenticationRequired ( MyComponent , {
46- claimCheck : ( claims : User ) =>
47- claims [ 'https://my.app.io/jwt/roles' ] ?. includes ( 'ADMIN' ) ,
45+ claimCheck : ( claims ? : User ) =>
46+ claims ?. [ 'https://my.app.io/jwt/roles' ] ?. includes ( 'ADMIN' ) ,
4847 } ) ;
4948 /**
5049 * A user with USER and MODERATOR roles.
@@ -72,8 +71,8 @@ describe('withAuthenticationRequired', () => {
7271 it ( 'should allow access to restricted components when JWT claims present' , async ( ) => {
7372 const MyComponent = ( ) : JSX . Element => < > Private</ > ;
7473 const WrappedComponent = withAuthenticationRequired ( MyComponent , {
75- claimCheck : ( claim : User ) =>
76- claim [ 'https://my.app.io/jwt/claims' ] ?. ROLE ?. includes ( 'ADMIN' ) ,
74+ claimCheck : ( claim ? : User ) =>
75+ claim ?. [ 'https://my.app.io/jwt/claims' ] ?. ROLE ?. includes ( 'ADMIN' ) ,
7776 } ) ;
7877 /**
7978 * User with ADMIN role.
0 commit comments