2020// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121// SOFTWARE.
2222
23- import * as analytics from '../../src/providers/analytics' ;
2423import { expect } from 'chai' ;
25- import { EventContext , Event } from '../../src/cloud-functions' ;
26- import * as analytics_spec_input from './analytics.spec.input ' ;
24+
25+ import { Event , EventContext } from '../../src/cloud-functions ' ;
2726import * as functions from '../../src/index' ;
27+ import * as analytics from '../../src/providers/analytics' ;
28+ import * as analytics_spec_input from './analytics.spec.input' ;
2829
2930describe ( 'Analytics Functions' , ( ) => {
3031 describe ( 'EventBuilder' , ( ) => {
@@ -37,7 +38,7 @@ describe('Analytics Functions', () => {
3738 } ) ;
3839
3940 it ( 'should allow both region and runtime options to be set' , ( ) => {
40- let fn = functions
41+ const fn = functions
4142 . region ( 'us-east1' )
4243 . runWith ( {
4344 timeoutSeconds : 90 ,
@@ -54,6 +55,7 @@ describe('Analytics Functions', () => {
5455 describe ( '#onLog' , ( ) => {
5556 it ( 'should return a TriggerDefinition with appropriate values' , ( ) => {
5657 const cloudFunction = analytics . event ( 'first_open' ) . onLog ( ( ) => null ) ;
58+
5759 expect ( cloudFunction . __trigger ) . to . deep . equal ( {
5860 eventTrigger : {
5961 eventType :
@@ -75,7 +77,7 @@ describe('Analytics Functions', () => {
7577
7678 // The event data delivered over the wire will be the JSON for an AnalyticsEvent:
7779 // https://firebase.google.com/docs/auth/admin/manage-users#retrieve_user_data
78- let event : Event = {
80+ const event : Event = {
7981 data : {
8082 userDim : {
8183 userId : 'hi!' ,
@@ -114,7 +116,7 @@ describe('Analytics Functions', () => {
114116 // Incoming events will have four kinds of "xValue" fields: "intValue",
115117 // "stringValue", "doubleValue" and "floatValue". We expect those to get
116118 // flattened away, leaving just their values.
117- let event : Event = {
119+ const event : Event = {
118120 data : {
119121 eventDim : [
120122 {
@@ -184,7 +186,7 @@ describe('Analytics Functions', () => {
184186 . event ( 'first_open' )
185187 . onLog ( ( data : analytics . AnalyticsEvent ) => data ) ;
186188
187- let event : Event = {
189+ const event : Event = {
188190 data : {
189191 eventDim : [
190192 {
@@ -254,7 +256,7 @@ describe('Analytics Functions', () => {
254256 //
255257 // Separately, the input has a number of microsecond timestamps that we'd
256258 // like to rename and scale down to milliseconds.
257- let event : Event = {
259+ const event : Event = {
258260 data : {
259261 eventDim : [
260262 {
@@ -291,11 +293,12 @@ describe('Analytics Functions', () => {
291293 . event ( 'first_open' )
292294 . onLog ( ( data : analytics . AnalyticsEvent ) => data ) ;
293295 // The payload in analytics_spec_input contains all possible fields at least once.
294- const data = analytics_spec_input . fullPayload . data ;
295- const context = analytics_spec_input . fullPayload . context ;
296- return expect ( cloudFunction ( data , context ) ) . to . eventually . deep . equal (
297- analytics_spec_input . data
298- ) ;
296+ const payloadData = analytics_spec_input . fullPayload . data ;
297+ const payloadContext = analytics_spec_input . fullPayload . context ;
298+
299+ return expect (
300+ cloudFunction ( payloadData , payloadContext )
301+ ) . to . eventually . deep . equal ( analytics_spec_input . data ) ;
299302 } ) ;
300303 } ) ;
301304 } ) ;
@@ -316,7 +319,7 @@ describe('Analytics Functions', () => {
316319
317320 // The event data delivered over the wire will be the JSON for an AnalyticsEvent:
318321 // https://firebase.google.com/docs/auth/admin/manage-users#retrieve_user_data
319- let event : Event = {
322+ const event : Event = {
320323 data : {
321324 userDim : {
322325 userId : 'hi!' ,
@@ -361,7 +364,8 @@ describe('Analytics Functions', () => {
361364 } ) ;
362365
363366 it ( 'should not throw when #run is called' , ( ) => {
364- let cf = analytics . event ( 'event' ) . onLog ( ( ) => null ) ;
367+ const cf = analytics . event ( 'event' ) . onLog ( ( ) => null ) ;
368+
365369 expect ( cf . run ) . to . not . throw ( Error ) ;
366370 } ) ;
367371 } ) ;
0 commit comments