@@ -407,6 +407,45 @@ describe('ServerlessStepFunctions', () => {
407
407
) ;
408
408
} ) ;
409
409
410
+ describe ( '#parseInputdate()' , ( ) => {
411
+ let fileExistsSyncStub ;
412
+ let readFileSyncStub ;
413
+ beforeEach ( ( ) => {
414
+ serverlessStepFunctions . serverless . config . servicePath = 'servicePath' ;
415
+ fileExistsSyncStub = sinon . stub ( serverlessStepFunctions . serverless . utils , 'fileExistsSync' )
416
+ . returns ( true ) ;
417
+ readFileSyncStub = sinon . stub ( serverlessStepFunctions . serverless . utils , 'readFileSync' )
418
+ . returns ( { foo : 'var' } ) ;
419
+ serverlessStepFunctions . options . data = null ;
420
+ serverlessStepFunctions . options . path = 'data.json' ;
421
+ } ) ;
422
+
423
+ it ( 'should throw error if file does not exists' , ( ) => {
424
+ serverlessStepFunctions . serverless . utils . fileExistsSync . restore ( ) ;
425
+ fileExistsSyncStub = sinon . stub ( serverlessStepFunctions . serverless . utils , 'fileExistsSync' )
426
+ . returns ( false ) ;
427
+ expect ( ( ) => serverlessStepFunctions . parseInputdate ( ) ) . to . throw ( Error ) ;
428
+ serverlessStepFunctions . serverless . utils . readFileSync . restore ( ) ;
429
+ } ) ;
430
+
431
+ it ( 'should parse file if path param is provided' , ( ) => {
432
+ return serverlessStepFunctions . parseInputdate ( ) . then ( ( ) => {
433
+ expect ( serverlessStepFunctions . options . data ) . to . deep . equal ( '{"foo":"var"}' ) ;
434
+ serverlessStepFunctions . serverless . utils . fileExistsSync . restore ( ) ;
435
+ serverlessStepFunctions . serverless . utils . readFileSync . restore ( ) ;
436
+ } ) ;
437
+ } ) ;
438
+
439
+ it ( 'should return resolve if path param is not provided' , ( ) => {
440
+ serverlessStepFunctions . options . path = null ;
441
+ return serverlessStepFunctions . parseInputdate ( ) . then ( ( ) => {
442
+ expect ( serverlessStepFunctions . options . data ) . to . deep . equal ( null ) ;
443
+ serverlessStepFunctions . serverless . utils . fileExistsSync . restore ( ) ;
444
+ serverlessStepFunctions . serverless . utils . readFileSync . restore ( ) ;
445
+ } ) ;
446
+ } ) ;
447
+ } ) ;
448
+
410
449
describe ( '#startExecution()' , ( ) => {
411
450
let startExecutionStub ;
412
451
beforeEach ( ( ) => {
0 commit comments