11import { expect } from 'chai' ;
2- import { CloudEvent , CloudFunction } from '../../../../src/v2/core' ;
32import * as options from '../../../../src/v2/options' ;
43import * as alerts from '../../../../src/v2/providers/alerts' ;
54import { FULL_ENDPOINT , FULL_OPTIONS } from '../helpers' ;
65
76const ALERT_TYPE = 'new-alert-type' ;
87const APPID = '123456789' ;
98
10- function getMockFunction ( ) : CloudFunction < alerts . FirebaseAlertData < String > > {
11- const func = ( raw : CloudEvent < unknown > ) => 42 ;
12- func . run = ( event : CloudEvent < alerts . FirebaseAlertData < String > > ) => 42 ;
13- func . __endpoint = { } ;
14- return func ;
15- }
16-
179describe ( 'alerts' , ( ) => {
1810 describe ( 'onAlertPublished' , ( ) => {
1911 it ( 'should create the function without opts' , ( ) => {
@@ -75,11 +67,7 @@ describe('alerts', () => {
7567 } ) ;
7668
7769 it ( 'should define the endpoint without appId and opts' , ( ) => {
78- const func = getMockFunction ( ) ;
79-
80- func . __endpoint = alerts . getEndpointAnnotation ( { } , ALERT_TYPE ) ;
81-
82- expect ( func . __endpoint ) . to . deep . equal ( {
70+ expect ( alerts . getEndpointAnnotation ( { } , ALERT_TYPE ) ) . to . deep . equal ( {
8371 platform : 'gcfv2' ,
8472 labels : { } ,
8573 eventTrigger : {
@@ -93,14 +81,9 @@ describe('alerts', () => {
9381 } ) ;
9482
9583 it ( 'should define a complex endpoint without appId' , ( ) => {
96- const func = getMockFunction ( ) ;
97-
98- func . __endpoint = alerts . getEndpointAnnotation (
99- { ...FULL_OPTIONS } ,
100- ALERT_TYPE
101- ) ;
102-
103- expect ( func . __endpoint ) . to . deep . equal ( {
84+ expect (
85+ alerts . getEndpointAnnotation ( { ...FULL_OPTIONS } , ALERT_TYPE )
86+ ) . to . deep . equal ( {
10487 ...FULL_ENDPOINT ,
10588 eventTrigger : {
10689 eventType : alerts . eventType ,
@@ -113,15 +96,9 @@ describe('alerts', () => {
11396 } ) ;
11497
11598 it ( 'should define a complex endpoint' , ( ) => {
116- const func = getMockFunction ( ) ;
117-
118- func . __endpoint = alerts . getEndpointAnnotation (
119- { ...FULL_OPTIONS } ,
120- ALERT_TYPE ,
121- APPID
122- ) ;
123-
124- expect ( func . __endpoint ) . to . deep . equal ( {
99+ expect (
100+ alerts . getEndpointAnnotation ( { ...FULL_OPTIONS } , ALERT_TYPE , APPID )
101+ ) . to . deep . equal ( {
125102 ...FULL_ENDPOINT ,
126103 eventTrigger : {
127104 eventType : alerts . eventType ,
@@ -144,15 +121,10 @@ describe('alerts', () => {
144121 region : 'us-west1' ,
145122 minInstances : 3 ,
146123 } ;
147- const func = getMockFunction ( ) ;
148-
149- func . __endpoint = alerts . getEndpointAnnotation (
150- specificOpts ,
151- ALERT_TYPE ,
152- APPID
153- ) ;
154124
155- expect ( func . __endpoint ) . to . deep . equal ( {
125+ expect (
126+ alerts . getEndpointAnnotation ( specificOpts , ALERT_TYPE , APPID )
127+ ) . to . deep . equal ( {
156128 platform : 'gcfv2' ,
157129 labels : { } ,
158130 concurrency : 20 ,
0 commit comments