2323import { expect } from 'chai' ;
2424
2525import { wrapV2 } from '../src/v2' ;
26+ import type { WrappedV2ScheduledFunction } from '../src/v2' ;
2627
2728import {
2829 CloudFunction ,
@@ -35,6 +36,7 @@ import {
3536 eventarc ,
3637 https ,
3738 firestore ,
39+ scheduler ,
3840} from 'firebase-functions/v2' ;
3941import { defineString } from 'firebase-functions/params' ;
4042import { makeDataSnapshot } from '../src/providers/database' ;
@@ -1422,6 +1424,41 @@ describe('v2', () => {
14221424 } ) ;
14231425 } ) ;
14241426
1427+ describe ( 'scheduler' , ( ) => {
1428+ describe ( 'onSchedule()' , ( ) => {
1429+ it ( 'should return correct data' , async ( ) => {
1430+ const scheduledFunction = scheduler . onSchedule (
1431+ 'every 5 minutes' ,
1432+ ( _e ) => { }
1433+ ) ;
1434+
1435+ scheduledFunction . __endpoint = {
1436+ platform : 'gcfv2' ,
1437+ labels : { } ,
1438+ scheduleTrigger : {
1439+ schedule : 'every 5 minutes' ,
1440+ } ,
1441+ concurrency : 20 ,
1442+ minInstances : 3 ,
1443+ region : [ 'us-west1' , 'us-central1' ] ,
1444+ } ;
1445+
1446+ let wrappedFunction : WrappedV2ScheduledFunction ;
1447+
1448+ expect (
1449+ ( ) => ( wrappedFunction = wrapV2 ( scheduledFunction ) )
1450+ ) . not . to . throw ( ) ;
1451+
1452+ const result = await wrappedFunction ( {
1453+ scheduleTime : '2024-01-01T00:00:00Z' ,
1454+ jobName : 'test-job' ,
1455+ } ) ;
1456+
1457+ expect ( result ) . to . be . undefined ;
1458+ } ) ;
1459+ } ) ;
1460+ } ) ;
1461+
14251462 describe ( 'callable functions' , ( ) => {
14261463 it ( 'should return correct data' , async ( ) => {
14271464 const cloudFunction = https . onCall ( ( ) => 'hello' ) ;
0 commit comments