-
-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Login token, logout method and set session cookie (#6)
* feat: 🎸 Exposes token on login status check ✅ Closes: #3 * feat: 🎸 Logout and set session cookie Added logout method and logout event. Also added method for setting sessionCookie from memory ✅ Closes: #4, #5
- Loading branch information
1 parent
dd1cdbd
commit 6eed165
Showing
10 changed files
with
139 additions
and
55 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,3 @@ | ||
{ | ||
"branches": ["main"] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import init, { Api } from './' | ||
import { list } from './children' | ||
import { Fetch } from './types' | ||
|
||
jest.mock('./login', () => { | ||
login: jest.fn() | ||
}) | ||
|
||
describe('api', () => { | ||
let fetch: jest.Mocked<Fetch> | ||
let clearCookies: jest.Mock | ||
let api: Api | ||
beforeEach(() => { | ||
fetch = jest.fn() | ||
clearCookies = jest.fn() | ||
api = init(fetch, clearCookies) | ||
}) | ||
describe('#logout', () => { | ||
it('clears cookies', async () => { | ||
await api.logout() | ||
expect(clearCookies).toHaveBeenCalled() | ||
}) | ||
it('emits logout event', async () => { | ||
const listener = jest.fn() | ||
api.on('logout', listener) | ||
await api.logout() | ||
expect(listener).toHaveBeenCalled() | ||
}) | ||
it('sets .isLoggedIn', async () => { | ||
api.isLoggedIn = true | ||
await api.logout() | ||
expect(api.isLoggedIn).toBe(false) | ||
}) | ||
}) | ||
}) |
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
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 |
---|---|---|
|
@@ -20,6 +20,7 @@ export interface Fetch { | |
|
||
export interface AuthTicket { | ||
order: string | ||
token: string | ||
} | ||
|
||
/** | ||
|
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