Skip to content

Commit 912a7cb

Browse files
committed
chore: lint and remove only from tests
1 parent eb514ce commit 912a7cb

File tree

4 files changed

+39
-32
lines changed

4 files changed

+39
-32
lines changed

lib/sessionManager/stores/expressSession.ts

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export class MemoryStorage<V extends string = StorageKeys>
1515
/**
1616
* Clears all items from session store.
1717
* @returns {void}
18-
.04
1918
*/
2019
async destroySession(): Promise<void> {
2120
this.memCache = {};

lib/utils/exchangeAuthCode.test.ts

+33-25
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
22
import { exchangeAuthCode } from ".";
33
import { MemoryStorage, StorageKeys } from "../sessionManager";
44
import { setActiveStorage } from "./token";
5-
import createFetchMock from 'vitest-fetch-mock';
5+
import createFetchMock from "vitest-fetch-mock";
66

77
const fetchMock = createFetchMock(vi);
88

9-
describe.only("exhangeAuthCode", () => {
9+
describe("exhangeAuthCode", () => {
1010
beforeEach(() => {
1111
fetchMock.enableMocks();
1212
});
13-
13+
1414
afterEach(() => {
15-
fetchMock.resetMocks();
15+
fetchMock.resetMocks();
1616
});
1717

18-
it.only("missing state param", async () => {
18+
it("missing state param", async () => {
1919
const urlParams = new URLSearchParams();
2020
urlParams.append("code", "test");
21-
21+
2222
const result = await exchangeAuthCode({
2323
urlParams,
2424
domain: "http://test.kinde.com",
@@ -32,10 +32,10 @@ describe.only("exhangeAuthCode", () => {
3232
});
3333
});
3434

35-
it.only("missing code param", async () => {
35+
it("missing code param", async () => {
3636
const urlParams = new URLSearchParams();
3737
urlParams.append("state", "test");
38-
38+
3939
const result = await exchangeAuthCode({
4040
urlParams,
4141
domain: "http://test.kinde.com",
@@ -49,20 +49,22 @@ describe.only("exhangeAuthCode", () => {
4949
});
5050
});
5151

52-
it.only("missing active storage", async () => {
52+
it("missing active storage", async () => {
5353
const urlParams = new URLSearchParams();
5454
urlParams.append("state", "test");
5555
urlParams.append("code", "test");
56-
57-
expect(exchangeAuthCode({
58-
urlParams,
59-
domain: "http://test.kinde.com",
60-
clientId: "test",
61-
redirectURL: "http://test.kinde.com",
62-
})).rejects.toThrowError("No active storage found");
56+
57+
expect(
58+
exchangeAuthCode({
59+
urlParams,
60+
domain: "http://test.kinde.com",
61+
clientId: "test",
62+
redirectURL: "http://test.kinde.com",
63+
}),
64+
).rejects.toThrowError("No active storage found");
6365
});
6466

65-
it.only("state mismatch", async () => {
67+
it("state mismatch", async () => {
6668
const store = new MemoryStorage();
6769
setActiveStorage(store);
6870

@@ -73,21 +75,20 @@ describe.only("exhangeAuthCode", () => {
7375
const urlParams = new URLSearchParams();
7476
urlParams.append("state", "test");
7577
urlParams.append("code", "test");
76-
77-
const result = await exchangeAuthCode({
78+
79+
const result = await exchangeAuthCode({
7880
urlParams,
7981
domain: "http://test.kinde.com",
8082
clientId: "test",
8183
redirectURL: "http://test.kinde.com",
82-
})
84+
});
8385

8486
expect(result).toStrictEqual({
8587
success: false,
8688
error: "Invalid state; supplied test, expected storedState",
8789
});
8890
});
8991

90-
9192
it("should encode a simple string", async () => {
9293
const store = new MemoryStorage();
9394
setActiveStorage(store);
@@ -104,8 +105,14 @@ describe.only("exhangeAuthCode", () => {
104105
urlParams.append("code", input);
105106
urlParams.append("state", state);
106107
urlParams.append("client_id", "test");
107-
108-
fetchMock.mockResponseOnce(JSON.stringify({ access_token: "access_token", refresh_token: "refresh_token", id_token: "id_token" }));
108+
109+
fetchMock.mockResponseOnce(
110+
JSON.stringify({
111+
access_token: "access_token",
112+
refresh_token: "refresh_token",
113+
id_token: "id_token",
114+
}),
115+
);
109116

110117
const result = await exchangeAuthCode({
111118
urlParams,
@@ -122,8 +129,9 @@ describe.only("exhangeAuthCode", () => {
122129

123130
const postStoredState = await store.getSessionItem(StorageKeys.state);
124131
expect(postStoredState).toBeNull();
125-
const postCodeVerifier = await store.getSessionItem(StorageKeys.codeVerifier);
132+
const postCodeVerifier = await store.getSessionItem(
133+
StorageKeys.codeVerifier,
134+
);
126135
expect(postCodeVerifier).toBeNull();
127136
});
128-
129137
});

lib/utils/exchangeAuthCode.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ export const exchangeAuthCode = async ({
1010
clientId,
1111
redirectURL,
1212
}: {
13-
urlParams: URLSearchParams,
14-
domain: string,
15-
clientId: string,
16-
redirectURL: string,
13+
urlParams: URLSearchParams;
14+
domain: string;
15+
clientId: string;
16+
redirectURL: string;
1717
}): Promise<unknown> => {
1818
const state = urlParams.get("state");
1919
const code = urlParams.get("code");
@@ -39,7 +39,7 @@ export const exchangeAuthCode = async ({
3939
);
4040
}
4141

42-
const storedState = await activeStorage.getSessionItem(StorageKeys.state)
42+
const storedState = await activeStorage.getSessionItem(StorageKeys.state);
4343
if (state !== storedState) {
4444
console.error("Invalid state");
4545
return {

lib/utils/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ export {
1414
sanatizeURL,
1515
generateAuthUrl,
1616
mapLoginMethodParamsForUrl,
17-
exchangeAuthCode
17+
exchangeAuthCode,
1818
};

0 commit comments

Comments
 (0)