This repository has been archived by the owner on Dec 28, 2021. It is now read-only.
forked from serverless/serverless-plugin-typescript
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from KingDarBoja/agiledigital/merge-master
fix: only process function if runtime is NodeJS
- Loading branch information
Showing
6 changed files
with
137 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,7 +78,7 @@ | |
], | ||
"guard-for-in": "off", | ||
"id-blacklist": [ | ||
"error", | ||
"off", | ||
"any", | ||
"Number", | ||
"number", | ||
|
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,111 @@ | ||
import TypeScriptPlugin from '../src' | ||
import { ServerlessTSInstance, ServerlessTSFunctionMap } from '../src/serverlessTypes' | ||
|
||
const createInstance = (functions: ServerlessTSFunctionMap, globalRuntime?: string): ServerlessTSInstance => ({ | ||
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: ServerlessTSFunctionMap = { | ||
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 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