1
1
import { expect } from 'chai' ;
2
- import { CloudEvent , CloudFunction } from '../../../../src/v2/core' ;
3
2
import * as options from '../../../../src/v2/options' ;
4
3
import * as alerts from '../../../../src/v2/providers/alerts' ;
5
4
import { FULL_ENDPOINT , FULL_OPTIONS } from '../helpers' ;
6
5
7
6
const ALERT_TYPE = 'new-alert-type' ;
8
7
const APPID = '123456789' ;
9
8
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
-
17
9
describe ( 'alerts' , ( ) => {
18
10
describe ( 'onAlertPublished' , ( ) => {
19
11
it ( 'should create the function without opts' , ( ) => {
@@ -75,11 +67,7 @@ describe('alerts', () => {
75
67
} ) ;
76
68
77
69
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 ( {
83
71
platform : 'gcfv2' ,
84
72
labels : { } ,
85
73
eventTrigger : {
@@ -93,14 +81,9 @@ describe('alerts', () => {
93
81
} ) ;
94
82
95
83
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 ( {
104
87
...FULL_ENDPOINT ,
105
88
eventTrigger : {
106
89
eventType : alerts . eventType ,
@@ -113,15 +96,9 @@ describe('alerts', () => {
113
96
} ) ;
114
97
115
98
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 ( {
125
102
...FULL_ENDPOINT ,
126
103
eventTrigger : {
127
104
eventType : alerts . eventType ,
@@ -144,15 +121,10 @@ describe('alerts', () => {
144
121
region : 'us-west1' ,
145
122
minInstances : 3 ,
146
123
} ;
147
- const func = getMockFunction ( ) ;
148
-
149
- func . __endpoint = alerts . getEndpointAnnotation (
150
- specificOpts ,
151
- ALERT_TYPE ,
152
- APPID
153
- ) ;
154
124
155
- expect ( func . __endpoint ) . to . deep . equal ( {
125
+ expect (
126
+ alerts . getEndpointAnnotation ( specificOpts , ALERT_TYPE , APPID )
127
+ ) . to . deep . equal ( {
156
128
platform : 'gcfv2' ,
157
129
labels : { } ,
158
130
concurrency : 20 ,
0 commit comments