@@ -3,11 +3,11 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
33import { POST } from "./route" ;
44
55const { reconcileGoogleCalendarConnectionsMock } = vi . hoisted ( ( ) => ( {
6- reconcileGoogleCalendarConnectionsMock : vi . fn ( )
6+ reconcileGoogleCalendarConnectionsMock : vi . fn ( ) ,
77} ) ) ;
88
99vi . mock ( "@/lib/server/google-calendar" , ( ) => ( {
10- reconcileGoogleCalendarConnections : reconcileGoogleCalendarConnectionsMock
10+ reconcileGoogleCalendarConnections : reconcileGoogleCalendarConnectionsMock ,
1111} ) ) ;
1212
1313describe ( "reconcile Google Calendar cron route" , ( ) => {
@@ -19,34 +19,36 @@ describe("reconcile Google Calendar cron route", () => {
1919 reconciledConnections : 0 ,
2020 syncedTasks : 0 ,
2121 outOfSyncTasks : 0 ,
22- failedConnections : 0
22+ failedConnections : 0 ,
2323 } ) ;
2424 } ) ;
2525
2626 it ( "rejects unauthenticated cron requests" , async ( ) => {
2727 process . env . CRON_SECRET = "cron-secret" ;
2828
29- const response = await POST ( new Request ( "http://localhost/api/cron/reconcile-google-calendar" ) ) ;
29+ const response = await POST (
30+ new Request ( "http://localhost/api/cron/reconcile-google-calendar" ) ,
31+ ) ;
3032
3133 expect ( response . status ) . toBe ( 401 ) ;
3234 await expect ( response . json ( ) ) . resolves . toMatchObject ( {
3335 accepted : false ,
34- error : "invalid_cron_secret"
36+ error : "invalid_cron_secret" ,
3537 } ) ;
3638 expect ( reconcileGoogleCalendarConnectionsMock ) . not . toHaveBeenCalled ( ) ;
3739 } ) ;
3840
3941 it ( "fails closed when the cron secret is not configured" , async ( ) => {
4042 const response = await POST (
4143 new Request ( "http://localhost/api/cron/reconcile-google-calendar" , {
42- method : "POST"
43- } )
44+ method : "POST" ,
45+ } ) ,
4446 ) ;
4547
4648 expect ( response . status ) . toBe ( 503 ) ;
4749 await expect ( response . json ( ) ) . resolves . toMatchObject ( {
4850 accepted : false ,
49- error : "cron_secret_not_configured"
51+ error : "cron_secret_not_configured" ,
5052 } ) ;
5153 } ) ;
5254
@@ -57,15 +59,15 @@ describe("reconcile Google Calendar cron route", () => {
5759 new Request ( "http://localhost/api/cron/reconcile-google-calendar" , {
5860 method : "POST" ,
5961 headers : {
60- authorization : "Bearer cron-secret"
61- }
62- } )
62+ authorization : "Bearer cron-secret" ,
63+ } ,
64+ } ) ,
6365 ) ;
6466
6567 expect ( response . status ) . toBe ( 200 ) ;
6668 await expect ( response . json ( ) ) . resolves . toMatchObject ( {
6769 accepted : true ,
68- reconciledConnections : 0
70+ reconciledConnections : 0 ,
6971 } ) ;
7072 expect ( reconcileGoogleCalendarConnectionsMock ) . toHaveBeenCalledTimes ( 1 ) ;
7173 } ) ;
0 commit comments