-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: multiple linting and test cases
- Loading branch information
1 parent
9e37e1e
commit d034344
Showing
10 changed files
with
1,313 additions
and
1,322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/react-auth-kit/src/__tests__/AuthContext.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//@ts-ignore | ||
import React from 'react'; | ||
|
||
import AuthKitContext from '../AuthContext'; | ||
import {useReactAuthKit} from '../AuthContext'; | ||
import {render} from '@testing-library/react'; | ||
import Cookies from 'js-cookie'; | ||
import TokenObject from '../RxTokenObject'; | ||
|
||
test('All Expected Exports are there', ()=>{ | ||
expect(AuthKitContext).toBeTruthy(); | ||
expect(useReactAuthKit).toBeTruthy(); | ||
}); | ||
|
||
test('Testing Conext Workflow', ()=>{ | ||
const TestComponent = () => { | ||
const c = useReactAuthKit(); | ||
return <div id="test"> {JSON.stringify(c.value)} </div>; | ||
}; | ||
|
||
const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM'+ | ||
'0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiZXhwIjo4MDA4NjA1MTk1fQ.ijw60'+ | ||
'3AjpAqNwnUXmv6YB5L6m5aL-llIgBsTJo-k2r8'; | ||
Cookies.set('__', token); | ||
|
||
const tokenObject = new TokenObject<object>( | ||
'__', | ||
'cookie', | ||
null, | ||
false, | ||
window.location.hostname, | ||
window.location.protocol === 'https:', | ||
); | ||
|
||
|
||
render( | ||
<AuthKitContext.Provider value={tokenObject as any}> | ||
<TestComponent/> | ||
</AuthKitContext.Provider>, | ||
); | ||
|
||
const data = document.querySelector('#test'); | ||
expect(data?.innerHTML).toEqual(` ${JSON.stringify(tokenObject.value)} `); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.