Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@propelauth/react

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@propelauth/react - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

dist/types/useAuthInfo.d.ts

2

package.json

@@ -8,3 +8,3 @@ {

},
"version": "1.2.2",
"version": "1.2.3",
"license": "MIT",

@@ -11,0 +11,0 @@ "keywords": [

@@ -9,2 +9,3 @@ /**

import { AuthProvider } from "./AuthContext"
import { useAuthInfo } from "./useAuthInfo"
import { useLogoutFunction } from "./useLogoutFunction"

@@ -94,2 +95,41 @@ import { useRedirectFunctions } from "./useRedirectFunctions"

it("useAuthInfo passes values correctly", async () => {
const accessToken = randomString()
const orgA = createOrg()
const orgB = createOrg()
const user = createUser()
const authenticationInfo = {
accessToken,
expiresAtSeconds: INITIAL_TIME_SECONDS + 30 * 60,
orgIdToOrgMemberInfo: {
[orgA.orgId]: orgA,
[orgB.orgId]: orgB,
},
user,
}
mockClient.getAuthenticationInfoOrNull.mockReturnValue(authenticationInfo)
const Component = () => {
const authInfo = useAuthInfo()
if (authInfo.loading) {
return <div>Loading...</div>
} else {
expect(authInfo.accessToken).toBe(accessToken)
expect(authInfo.user).toStrictEqual(user)
expect(authInfo.isLoggedIn).toBe(true)
expect(authInfo.orgHelper.getOrgs().sort()).toEqual([orgA, orgB].sort())
return <div>Finished</div>
}
}
render(
<AuthProvider authUrl={AUTH_URL}>
<Component />
</AuthProvider>
)
await waitFor(() => screen.getByText("Finished"))
expectCreateClientWasCalledCorrectly()
})
it("withAuthInfo passes logged out values from client as props", async () => {

@@ -117,2 +157,28 @@ mockClient.getAuthenticationInfoOrNull.mockReturnValue(null)

it("useAuthInfo passes logged out values from client as props", async () => {
mockClient.getAuthenticationInfoOrNull.mockReturnValue(null)
const Component = () => {
const authInfo = useAuthInfo()
if (authInfo.loading) {
return <div>Loading...</div>
} else {
expect(authInfo.accessToken).toBe(null)
expect(authInfo.user).toBe(null)
expect(authInfo.isLoggedIn).toBe(false)
expect(authInfo.orgHelper).toBe(null)
return <div>Finished</div>
}
}
render(
<AuthProvider authUrl={AUTH_URL}>
<Component />
</AuthProvider>
)
await waitFor(() => screen.getByText("Finished"))
expectCreateClientWasCalledCorrectly()
})
it("redirectToLoginPage calls into the client", async () => {

@@ -119,0 +185,0 @@ const Component = () => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc