Skip to content

Commit

Permalink
feat: allow adding a default user session
Browse files Browse the repository at this point in the history
  • Loading branch information
dcshzj committed Nov 22, 2022
1 parent cc99b87 commit 960bd2e
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/fixtures/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import {
mockUserSessionData,
mockUserWithSiteSessionData,
mockGithubSessionData,
MOCK_USER_SESSION_DATA_ONE,
} from "./sessionData"
import { MOCK_SITE_NAME_ONE } from "./sites"

/**
* @deprecated
Expand Down Expand Up @@ -72,6 +74,28 @@ const attachUserSessionDataWithSite: (
next()
}

const attachDefaultUserSessionData: RequestHandler<
unknown,
unknown,
unknown,
unknown,
{ userSessionData: UserSessionData }
> = attachUserSessionData(MOCK_USER_SESSION_DATA_ONE)

const attachDefaultUserSessionDataWithSite: RequestHandler<
unknown,
unknown,
unknown,
unknown,
{
userSessionData: UserSessionData
userWithSiteSessionData: UserWithSiteSessionData
}
> = attachUserSessionDataWithSite(
MOCK_USER_SESSION_DATA_ONE,
MOCK_SITE_NAME_ONE
)

/**
* @deprecated
*/
Expand Down
28 changes: 28 additions & 0 deletions src/fixtures/sessionData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ import GithubSessionData from "@root/classes/GithubSessionData"
import UserSessionData from "@root/classes/UserSessionData"
import UserWithSiteSessionData from "@root/classes/UserWithSiteSessionData"

import {
MOCK_USER_EMAIL_ONE,
MOCK_USER_EMAIL_TWO,
MOCK_USER_EMAIL_THREE,
MOCK_USER_EMAIL_FOUR,
MOCK_USER_ID_ONE,
MOCK_USER_ID_TWO,
MOCK_USER_ID_THREE,
MOCK_USER_ID_FOUR,
} from "./users"

export const mockAccessToken = "mockAccessToken"
export const mockGithubId = "mockGithubId"
export const mockIsomerUserId = "1"
Expand Down Expand Up @@ -43,3 +54,20 @@ export const mockSessionDataEmailUserWithSite = new UserWithSiteSessionData({
email: mockEmail,
siteName: mockSiteName,
})

export const MOCK_USER_SESSION_DATA_ONE = new UserSessionData({
isomerUserId: String(MOCK_USER_ID_ONE),
email: MOCK_USER_EMAIL_ONE,
})
export const MOCK_USER_SESSION_DATA_TWO = new UserSessionData({
isomerUserId: String(MOCK_USER_ID_TWO),
email: MOCK_USER_EMAIL_TWO,
})
export const MOCK_USER_SESSION_DATA_THREE = new UserSessionData({
isomerUserId: String(MOCK_USER_ID_THREE),
email: MOCK_USER_EMAIL_THREE,
})
export const MOCK_USER_SESSION_DATA_FOUR = new UserSessionData({
isomerUserId: String(MOCK_USER_ID_FOUR),
email: MOCK_USER_EMAIL_FOUR,
})
2 changes: 2 additions & 0 deletions src/fixtures/sites.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const MOCK_SITE_NAME_ONE = "test-site-one"
export const MOCK_SITE_NAME_TWO = "test-site-two"
9 changes: 9 additions & 0 deletions src/fixtures/users.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const MOCK_USER_ID_ONE = 1
export const MOCK_USER_ID_TWO = 2
export const MOCK_USER_ID_THREE = 3
export const MOCK_USER_ID_FOUR = 4

export const MOCK_USER_EMAIL_ONE = "[email protected]"
export const MOCK_USER_EMAIL_TWO = "[email protected]"
export const MOCK_USER_EMAIL_THREE = "[email protected]"
export const MOCK_USER_EMAIL_FOUR = "[email protected]"

0 comments on commit 960bd2e

Please sign in to comment.