Skip to content

Commit

Permalink
Update mocking of rwjs/auth-dbauth-api
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Actions committed Jul 11, 2024
1 parent 286350d commit 889d94a
Showing 1 changed file with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,24 @@ beforeAll(() => {
vi.mock('@redwoodjs/auth-dbauth-api', async (importOriginal) => {
const original = (await importOriginal()) as any
return {
...original,
dbAuthSession: vi.fn().mockImplementation((req, cookieName) => {
if (
req.headers
.get('Cookie')
.includes(`${cookieName}=this_is_the_only_correct_session`)
) {
return {
currentUser: {
email: 'user-1@example.com',
id: 'mocked-current-user-1',
},
mockedSession: 'this_is_the_only_correct_session',
default: {
...original,
dbAuthSession: vi.fn().mockImplementation((req, cookieName) => {
if (
req.headers
.get('Cookie')
.includes(`${cookieName}=this_is_the_only_correct_session`)
) {
return {
currentUser: {
email: 'user-1@example.com',
id: 'mocked-current-user-1',
},
mockedSession: 'this_is_the_only_correct_session',
}
}
}
}),
}),
},
}
})
})
Expand Down

0 comments on commit 889d94a

Please sign in to comment.