@@ -2,23 +2,23 @@ import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
2
2
import { exchangeAuthCode } from "." ;
3
3
import { MemoryStorage , StorageKeys } from "../sessionManager" ;
4
4
import { setActiveStorage } from "./token" ;
5
- import createFetchMock from ' vitest-fetch-mock' ;
5
+ import createFetchMock from " vitest-fetch-mock" ;
6
6
7
7
const fetchMock = createFetchMock ( vi ) ;
8
8
9
- describe . only ( "exhangeAuthCode" , ( ) => {
9
+ describe ( "exhangeAuthCode" , ( ) => {
10
10
beforeEach ( ( ) => {
11
11
fetchMock . enableMocks ( ) ;
12
12
} ) ;
13
-
13
+
14
14
afterEach ( ( ) => {
15
- fetchMock . resetMocks ( ) ;
15
+ fetchMock . resetMocks ( ) ;
16
16
} ) ;
17
17
18
- it . only ( "missing state param" , async ( ) => {
18
+ it ( "missing state param" , async ( ) => {
19
19
const urlParams = new URLSearchParams ( ) ;
20
20
urlParams . append ( "code" , "test" ) ;
21
-
21
+
22
22
const result = await exchangeAuthCode ( {
23
23
urlParams,
24
24
domain : "http://test.kinde.com" ,
@@ -32,10 +32,10 @@ describe.only("exhangeAuthCode", () => {
32
32
} ) ;
33
33
} ) ;
34
34
35
- it . only ( "missing code param" , async ( ) => {
35
+ it ( "missing code param" , async ( ) => {
36
36
const urlParams = new URLSearchParams ( ) ;
37
37
urlParams . append ( "state" , "test" ) ;
38
-
38
+
39
39
const result = await exchangeAuthCode ( {
40
40
urlParams,
41
41
domain : "http://test.kinde.com" ,
@@ -49,20 +49,22 @@ describe.only("exhangeAuthCode", () => {
49
49
} ) ;
50
50
} ) ;
51
51
52
- it . only ( "missing active storage" , async ( ) => {
52
+ it ( "missing active storage" , async ( ) => {
53
53
const urlParams = new URLSearchParams ( ) ;
54
54
urlParams . append ( "state" , "test" ) ;
55
55
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" ) ;
63
65
} ) ;
64
66
65
- it . only ( "state mismatch" , async ( ) => {
67
+ it ( "state mismatch" , async ( ) => {
66
68
const store = new MemoryStorage ( ) ;
67
69
setActiveStorage ( store ) ;
68
70
@@ -73,21 +75,20 @@ describe.only("exhangeAuthCode", () => {
73
75
const urlParams = new URLSearchParams ( ) ;
74
76
urlParams . append ( "state" , "test" ) ;
75
77
urlParams . append ( "code" , "test" ) ;
76
-
77
- const result = await exchangeAuthCode ( {
78
+
79
+ const result = await exchangeAuthCode ( {
78
80
urlParams,
79
81
domain : "http://test.kinde.com" ,
80
82
clientId : "test" ,
81
83
redirectURL : "http://test.kinde.com" ,
82
- } )
84
+ } ) ;
83
85
84
86
expect ( result ) . toStrictEqual ( {
85
87
success : false ,
86
88
error : "Invalid state; supplied test, expected storedState" ,
87
89
} ) ;
88
90
} ) ;
89
91
90
-
91
92
it ( "should encode a simple string" , async ( ) => {
92
93
const store = new MemoryStorage ( ) ;
93
94
setActiveStorage ( store ) ;
@@ -104,8 +105,14 @@ describe.only("exhangeAuthCode", () => {
104
105
urlParams . append ( "code" , input ) ;
105
106
urlParams . append ( "state" , state ) ;
106
107
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
+ ) ;
109
116
110
117
const result = await exchangeAuthCode ( {
111
118
urlParams,
@@ -122,8 +129,9 @@ describe.only("exhangeAuthCode", () => {
122
129
123
130
const postStoredState = await store . getSessionItem ( StorageKeys . state ) ;
124
131
expect ( postStoredState ) . toBeNull ( ) ;
125
- const postCodeVerifier = await store . getSessionItem ( StorageKeys . codeVerifier ) ;
132
+ const postCodeVerifier = await store . getSessionItem (
133
+ StorageKeys . codeVerifier ,
134
+ ) ;
126
135
expect ( postCodeVerifier ) . toBeNull ( ) ;
127
136
} ) ;
128
-
129
137
} ) ;
0 commit comments