@@ -7,6 +7,7 @@ require('chai').use(chaiAsPromised);
7
7
8
8
const sinon = require ( 'sinon' ) ;
9
9
const Node = require ( '../node' ) ;
10
+ const BaseRuntime = require ( '../base' ) ;
10
11
const JSZip = require ( "jszip" ) ;
11
12
const fs = require ( 'fs-extra' ) ;
12
13
@@ -96,6 +97,28 @@ describe('Node', () => {
96
97
} )
97
98
} ) ;
98
99
100
+ describe ( '#isValidTypeScriptFile()' , ( ) => {
101
+ it ( 'should report valid file path when a js path is passed that has a ts file instead' , ( ) => {
102
+ //We need to mock the node's `super` call, which is why we're using BaseRuntime
103
+ sandbox . stub ( BaseRuntime . prototype , 'isValidFile' , ( path ) => {
104
+ expect ( path ) . to . equal ( 'valid_typescript_handler_wrong_extension.ts' ) ;
105
+ return true ;
106
+ } ) ;
107
+ expect ( node . isValidTypeScriptFile ( 'valid_typescript_handler_wrong_extension.js' ) ) . to . equal ( true )
108
+ } ) ;
109
+ } ) ;
110
+
111
+ describe ( '#isValidFile()' , ( ) => {
112
+ it ( 'should still allow a js file to be used for handler' , ( ) => {
113
+ //We need to mock the node's `super` call, which is why we're using BaseRuntime
114
+ sandbox . stub ( BaseRuntime . prototype , 'isValidFile' , ( path ) => {
115
+ expect ( path ) . to . equal ( 'valid_js_handler.js' ) ;
116
+ return true ;
117
+ } ) ;
118
+ expect ( node . isValidFile ( 'valid_js_handler.js' ) ) . to . equal ( true )
119
+ } ) ;
120
+ } ) ;
121
+
99
122
describe ( '#generateActionPackage()' , ( ) => {
100
123
it ( 'should throw error for missing handler file' , ( ) => {
101
124
expect ( ( ) => node . generateActionPackage ( { handler : 'does_not_exist.main' } ) )
0 commit comments