2121// SOFTWARE.
2222
2323import { expect } from 'chai' ;
24- import * as pubsub from '../../src/providers/pubsub' ;
25- import * as functions from '../../src/index' ;
2624import { Event } from '../../src/index' ;
25+ import * as functions from '../../src/index' ;
26+ import * as pubsub from '../../src/providers/pubsub' ;
2727
2828describe ( 'Pubsub Functions' , ( ) => {
2929 describe ( 'pubsub.Message' , ( ) => {
3030 describe ( '#json' , ( ) => {
3131 it ( 'should return json decoded from base64' , ( ) => {
32- let message = new pubsub . Message ( {
32+ const message = new pubsub . Message ( {
3333 data : new Buffer ( '{"hello":"world"}' , 'utf8' ) . toString ( 'base64' ) ,
3434 } ) ;
3535
3636 expect ( message . json . hello ) . to . equal ( 'world' ) ;
3737 } ) ;
3838
3939 it ( 'should preserve passed in json' , ( ) => {
40- let message = new pubsub . Message ( {
40+ const message = new pubsub . Message ( {
4141 data : new Buffer ( '{"hello":"world"}' , 'utf8' ) . toString ( 'base64' ) ,
4242 json : { goodbye : 'world' } ,
4343 } ) ;
@@ -48,10 +48,10 @@ describe('Pubsub Functions', () => {
4848
4949 describe ( '#toJSON' , ( ) => {
5050 it ( 'should be JSON stringify-able' , ( ) => {
51- let encoded = new Buffer ( '{"hello":"world"}' , 'utf8' ) . toString (
51+ const encoded = new Buffer ( '{"hello":"world"}' , 'utf8' ) . toString (
5252 'base64'
5353 ) ;
54- let message = new pubsub . Message ( {
54+ const message = new pubsub . Message ( {
5555 data : encoded ,
5656 } ) ;
5757
@@ -73,7 +73,7 @@ describe('Pubsub Functions', () => {
7373 } ) ;
7474
7575 it ( 'should allow both region and runtime options to be set' , ( ) => {
76- let fn = functions
76+ const fn = functions
7777 . region ( 'us-east1' )
7878 . runWith ( {
7979 timeoutSeconds : 90 ,
@@ -144,14 +144,16 @@ describe('Pubsub Functions', () => {
144144
145145 describe ( '#schedule' , ( ) => {
146146 it ( 'should return a trigger with schedule' , ( ) => {
147- let result = pubsub . schedule ( 'every 5 minutes' ) . onRun ( context => null ) ;
147+ const result = pubsub
148+ . schedule ( 'every 5 minutes' )
149+ . onRun ( context => null ) ;
148150 expect ( result . __trigger . schedule ) . to . deep . equal ( {
149151 schedule : 'every 5 minutes' ,
150152 } ) ;
151153 } ) ;
152154
153155 it ( 'should return a trigger with schedule and timeZone when one is chosen' , ( ) => {
154- let result = pubsub
156+ const result = pubsub
155157 . schedule ( 'every 5 minutes' )
156158 . timeZone ( 'America/New_York' )
157159 . onRun ( context => null ) ;
@@ -162,51 +164,55 @@ describe('Pubsub Functions', () => {
162164 } ) ;
163165
164166 it ( 'should return a trigger with schedule and retry config when called with retryConfig' , ( ) => {
165- let retryConfig = {
167+ const retryConfig = {
166168 retryCount : 3 ,
167169 maxRetryDuration : '10 minutes' ,
168170 minBackoffDuration : '10 minutes' ,
169171 maxBackoffDuration : '10 minutes' ,
170172 maxDoublings : 5 ,
171173 } ;
172- let result = pubsub
174+ const result = pubsub
173175 . schedule ( 'every 5 minutes' )
174176 . retryConfig ( retryConfig )
175177 . onRun ( ( ) => null ) ;
176178 expect ( result . __trigger . schedule ) . to . deep . equal ( {
177179 schedule : 'every 5 minutes' ,
178- retryConfig : retryConfig ,
180+ retryConfig,
179181 } ) ;
180182 expect ( result . __trigger . labels ) . to . deep . equal ( {
181183 'deployment-scheduled' : 'true' ,
182184 } ) ;
183185 } ) ;
184186
185- it ( 'should return a trigger with schedule, timeZone and retry config when called with retryConfig and timeout' , ( ) => {
186- let retryConfig = {
187- retryCount : 3 ,
188- maxRetryDuration : '10 minutes' ,
189- minBackoffDuration : '10 minutes' ,
190- maxBackoffDuration : '10 minutes' ,
191- maxDoublings : 5 ,
192- } ;
193- let result = pubsub
194- . schedule ( 'every 5 minutes' )
195- . timeZone ( 'America/New_York' )
196- . retryConfig ( retryConfig )
197- . onRun ( ( ) => null ) ;
198- expect ( result . __trigger . schedule ) . to . deep . equal ( {
199- schedule : 'every 5 minutes' ,
200- retryConfig : retryConfig ,
201- timeZone : 'America/New_York' ,
202- } ) ;
203- expect ( result . __trigger . labels ) . to . deep . equal ( {
204- 'deployment-scheduled' : 'true' ,
205- } ) ;
206- } ) ;
187+ it (
188+ 'should return a trigger with schedule, timeZone and retry config' +
189+ 'when called with retryConfig and timeout' ,
190+ ( ) => {
191+ const retryConfig = {
192+ retryCount : 3 ,
193+ maxRetryDuration : '10 minutes' ,
194+ minBackoffDuration : '10 minutes' ,
195+ maxBackoffDuration : '10 minutes' ,
196+ maxDoublings : 5 ,
197+ } ;
198+ const result = pubsub
199+ . schedule ( 'every 5 minutes' )
200+ . timeZone ( 'America/New_York' )
201+ . retryConfig ( retryConfig )
202+ . onRun ( ( ) => null ) ;
203+ expect ( result . __trigger . schedule ) . to . deep . equal ( {
204+ schedule : 'every 5 minutes' ,
205+ retryConfig,
206+ timeZone : 'America/New_York' ,
207+ } ) ;
208+ expect ( result . __trigger . labels ) . to . deep . equal ( {
209+ 'deployment-scheduled' : 'true' ,
210+ } ) ;
211+ }
212+ ) ;
207213
208214 it ( 'should return an appropriate trigger when called with region and options' , ( ) => {
209- let result = functions
215+ const result = functions
210216 . region ( 'us-east1' )
211217 . runWith ( {
212218 timeoutSeconds : 90 ,
@@ -223,7 +229,7 @@ describe('Pubsub Functions', () => {
223229 } ) ;
224230
225231 it ( 'should return an appropriate trigger when called with region, timeZone, and options' , ( ) => {
226- let result = functions
232+ const result = functions
227233 . region ( 'us-east1' )
228234 . runWith ( {
229235 timeoutSeconds : 90 ,
@@ -242,14 +248,14 @@ describe('Pubsub Functions', () => {
242248 } ) ;
243249
244250 it ( 'should return an appropriate trigger when called with region, options and retryConfig' , ( ) => {
245- let retryConfig = {
251+ const retryConfig = {
246252 retryCount : 3 ,
247253 maxRetryDuration : '10 minutes' ,
248254 minBackoffDuration : '10 minutes' ,
249255 maxBackoffDuration : '10 minutes' ,
250256 maxDoublings : 5 ,
251257 } ;
252- let result = functions
258+ const result = functions
253259 . region ( 'us-east1' )
254260 . runWith ( {
255261 timeoutSeconds : 90 ,
@@ -260,7 +266,7 @@ describe('Pubsub Functions', () => {
260266 . onRun ( ( ) => null ) ;
261267 expect ( result . __trigger . schedule ) . to . deep . equal ( {
262268 schedule : 'every 5 minutes' ,
263- retryConfig : retryConfig ,
269+ retryConfig,
264270 } ) ;
265271 expect ( result . __trigger . labels ) . to . deep . equal ( {
266272 'deployment-scheduled' : 'true' ,
@@ -271,14 +277,14 @@ describe('Pubsub Functions', () => {
271277 } ) ;
272278
273279 it ( 'should return an appropriate trigger when called with region, options, retryConfig, and timeZone' , ( ) => {
274- let retryConfig = {
280+ const retryConfig = {
275281 retryCount : 3 ,
276282 maxRetryDuration : '10 minutes' ,
277283 minBackoffDuration : '10 minutes' ,
278284 maxBackoffDuration : '10 minutes' ,
279285 maxDoublings : 5 ,
280286 } ;
281- let result = functions
287+ const result = functions
282288 . region ( 'us-east1' )
283289 . runWith ( {
284290 timeoutSeconds : 90 ,
@@ -291,7 +297,7 @@ describe('Pubsub Functions', () => {
291297 expect ( result . __trigger . schedule ) . to . deep . equal ( {
292298 schedule : 'every 5 minutes' ,
293299 timeZone : 'America/New_York' ,
294- retryConfig : retryConfig ,
300+ retryConfig,
295301 } ) ;
296302 expect ( result . __trigger . labels ) . to . deep . equal ( {
297303 'deployment-scheduled' : 'true' ,
@@ -363,7 +369,7 @@ describe('Pubsub Functions', () => {
363369 } ) ;
364370
365371 it ( 'should not throw when #run is called' , ( ) => {
366- let cf = pubsub . topic ( 'toppy' ) . onPublish ( ( ) => null ) ;
372+ const cf = pubsub . topic ( 'toppy' ) . onPublish ( ( ) => null ) ;
367373 expect ( cf . run ) . to . not . throw ( Error ) ;
368374 } ) ;
369375 } ) ;
0 commit comments