@@ -43,11 +43,16 @@ const caseRecord = {
4343
4444const casesList = [ { target_id : "target" , target_tag : "target#0001" , cases_count : 2 } ] ;
4545const appealsList = [
46- { appeal_id : "1" , guild_id : "222078108977594368" , created_at : "2024-01-01T00:00:00.000Z" , reason : "appeal" } ,
46+ {
47+ appeal_id : "1" ,
48+ guild_id : "222078108977594368" ,
49+ created_at : "2024-01-01T00:00:00.000Z" ,
50+ reason : "appeal" ,
51+ } ,
4752] ;
4853
4954const sqlMock = createSqlMock < any > ( async ( strings ?: TemplateStringsArray ) => {
50- const query = strings ?. [ 0 ] ?? "" ;
55+ const query = strings ?. join ( "" ) ?? "" ;
5156
5257 if ( query . includes ( "from cases" ) && query . includes ( "limit 1" ) ) {
5358 return [ caseRecord ] ;
@@ -111,14 +116,22 @@ describe("api", () => {
111116 } ) ;
112117
113118 it ( "responds to root route" , async ( ) => {
114- const res = await api . inject ( { method : "GET" , url : "/api/" , headers : authHeader } ) ;
119+ const res = await api . inject ( {
120+ method : "GET" ,
121+ url : "/api/" ,
122+ headers : authHeader ,
123+ } ) ;
115124
116125 expect ( res . statusCode ) . toBe ( 200 ) ;
117126 expect ( res . body ) . toBe ( "Welcome to the yuudachi api." ) ;
118127 } ) ;
119128
120129 it ( "returns banned user details" , async ( ) => {
121- const res = await api . inject ( { method : "GET" , url : "/api/users/user-id" , headers : authHeader } ) ;
130+ const res = await api . inject ( {
131+ method : "GET" ,
132+ url : "/api/users/user-id" ,
133+ headers : authHeader ,
134+ } ) ;
122135 const body = res . json ( ) ;
123136
124137 expect ( body . banned ) . toBe ( true ) ;
@@ -129,21 +142,34 @@ describe("api", () => {
129142 it ( "returns non-banned state when ban lookup fails" , async ( ) => {
130143 bansFetch . mockRejectedValue ( new Error ( "not banned" ) ) ;
131144
132- const res = await api . inject ( { method : "GET" , url : "/api/users/user-id" , headers : authHeader } ) ;
145+ const res = await api . inject ( {
146+ method : "GET" ,
147+ url : "/api/users/user-id" ,
148+ headers : authHeader ,
149+ } ) ;
133150
134151 expect ( res . json ( ) ) . toEqual ( { banned : false } ) ;
135152 } ) ;
136153
137154 it ( "lists cases with counts" , async ( ) => {
138- const res = await api . inject ( { method : "GET" , url : "/api/cases" , headers : authHeader } ) ;
155+ const res = await api . inject ( {
156+ method : "GET" ,
157+ url : "/api/guilds/222078108977594368/cases" ,
158+ headers : authHeader ,
159+ } ) ;
139160 const body = res . json ( ) ;
140161
141162 expect ( body . cases ) . toEqual ( casesList ) ;
142163 expect ( body . count ) . toBe ( 2 ) ;
143164 } ) ;
144165
145166 it ( "returns cases for a single user" , async ( ) => {
146- const res = await api . inject ( { method : "GET" , url : "/api/cases/user-id" , headers : authHeader } ) ;
167+ const res = await api . inject ( {
168+ method : "GET" ,
169+ url : "/api/guilds/222078108977594368/cases/user-id" ,
170+ headers : authHeader ,
171+ } ) ;
172+
147173 const body = res . json ( ) ;
148174
149175 expect ( body . user . id ) . toBe ( "user-id" ) ;
@@ -152,7 +178,11 @@ describe("api", () => {
152178 } ) ;
153179
154180 it ( "returns appeals overview" , async ( ) => {
155- const res = await api . inject ( { method : "GET" , url : "/api/appeals" , headers : authHeader } ) ;
181+ const res = await api . inject ( {
182+ method : "GET" ,
183+ url : "/api/appeals" ,
184+ headers : authHeader ,
185+ } ) ;
156186 const body = res . json ( ) ;
157187
158188 expect ( body . appeals ) . toEqual ( appealsList ) ;
0 commit comments