-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'vectorjohn/master'
- Merge in the changes that vectorjohn made in a parallel PR (filtering functions at the plugin level) - Use lodash's pickBy to simplify some logic - Fix an issue with mixed export syntax (export vs module.exports) - Removed redundant tests Fixes #198
- Loading branch information
Showing
6 changed files
with
140 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import TypeScriptPlugin from '../src' | ||
|
||
const createInstance = (functions: Serverless.FunctionMap, globalRuntime?: string): Serverless.Instance => ({ | ||
cli: { | ||
log: jest.fn() | ||
}, | ||
config: { | ||
servicePath: 'servicePath' | ||
}, | ||
service: { | ||
provider: { | ||
name: 'aws', | ||
runtime: globalRuntime | ||
}, | ||
package: { | ||
individually: true, | ||
include: [], | ||
exclude: [] | ||
}, | ||
functions, | ||
getAllFunctions: jest.fn() | ||
}, | ||
pluginManager: { | ||
spawn: jest.fn() | ||
} | ||
}) | ||
|
||
describe('functions', () => { | ||
const functions: Serverless.FunctionMap = { | ||
hello: { | ||
handler: 'tests/assets/hello.handler', | ||
package: { | ||
include: [], | ||
exclude: [] | ||
} | ||
}, | ||
world: { | ||
handler: 'tests/assets/world.handler', | ||
runtime: 'nodejs12.x', | ||
package: { | ||
include: [], | ||
exclude: [] | ||
}, | ||
}, | ||
js: { | ||
handler: 'tests/assets/jsfile.create', | ||
package: { | ||
include: [], | ||
exclude: [] | ||
} | ||
}, | ||
notActuallyTypescript: { | ||
handler: 'tests/assets/jsfile.create', | ||
package: { | ||
include: [], | ||
exclude: [] | ||
}, | ||
runtime: 'go1.x' | ||
}, | ||
} | ||
|
||
describe('when the provider runtime is Node', () => { | ||
it('can get filter out non node based functions', () => { | ||
const slsInstance = createInstance(functions, 'nodejs10.x') | ||
const plugin = new TypeScriptPlugin(slsInstance, {}) | ||
|
||
expect( | ||
Object.values(plugin.functions).map(fn => fn.handler), | ||
).toEqual( | ||
[ | ||
'tests/assets/hello.handler', | ||
'tests/assets/world.handler', | ||
'tests/assets/jsfile.create', | ||
], | ||
) | ||
}) | ||
}) | ||
|
||
describe('when the provider runtime is not Node', () => { | ||
it('can get filter out non node based functions', () => { | ||
const slsInstance = createInstance(functions, 'python2.7') | ||
const plugin = new TypeScriptPlugin(slsInstance, {}) | ||
|
||
expect( | ||
Object.values(plugin.functions).map(fn => fn.handler), | ||
).toEqual( | ||
[ | ||
'tests/assets/world.handler', | ||
], | ||
) | ||
}) | ||
}) | ||
|
||
describe('when the provider runtime is undefined', () => { | ||
it('can get filter out non node based functions', () => { | ||
const slsInstance = createInstance(functions) | ||
const plugin = new TypeScriptPlugin(slsInstance, {}) | ||
|
||
expect( | ||
Object.values(plugin.functions).map(fn => fn.handler), | ||
).toEqual( | ||
[ | ||
'tests/assets/hello.handler', | ||
'tests/assets/world.handler', | ||
'tests/assets/jsfile.create', | ||
], | ||
) | ||
}) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters