55
66const _ = require ( 'lodash' ) ;
77const BbPromise = require ( 'bluebird' ) ;
8+ const semver = require ( 'semver' ) ;
89const Serverless = require ( 'serverless' ) ;
910const ServerlessWebpack = require ( '../index' ) ;
1011
@@ -23,7 +24,9 @@ describe('ServerlessWebpack', () => {
2324 } ;
2425 serverless . pluginManager . spawn = jest . fn ( ) . mockReturnValue ( BbPromise . resolve ( ) ) ;
2526 serverless . service . getFunction = jest . fn ( ) . mockReturnValue ( { runtime : 'nodejs12.x' } ) ;
26- serverless . configSchemaHandler . defineFunctionProperties = jest . fn ( ) ;
27+ if ( semver . gte ( serverless . getVersion ( ) , '2.10.0' ) ) {
28+ serverless . configSchemaHandler . defineFunctionProperties = jest . fn ( ) ;
29+ }
2730 } ) ;
2831
2932 it ( 'should expose a lib object' , ( ) => {
@@ -33,11 +36,15 @@ describe('ServerlessWebpack', () => {
3336
3437 it ( 'should extend serverless' , ( ) => {
3538 new ServerlessWebpack ( serverless , { } ) ;
36- expect ( serverless . configSchemaHandler . defineFunctionProperties ) . toHaveBeenCalledWith ( 'aws' , {
37- properties : {
38- entrypoint : { type : 'string' }
39- }
40- } ) ;
39+ if ( semver . gte ( serverless . getVersion ( ) , '2.10.0' ) ) {
40+ expect ( serverless . configSchemaHandler . defineFunctionProperties ) . toHaveBeenCalledWith ( 'aws' , {
41+ properties : {
42+ entrypoint : { type : 'string' }
43+ }
44+ } ) ;
45+ } else {
46+ expect ( serverless . configSchemaHandler . defineFunctionProperties ) . toBeUndefined ( ) ;
47+ }
4148 } ) ;
4249
4350 describe ( 'with a TS webpack configuration' , ( ) => {
0 commit comments