You've already forked serverless-plugin-typescript
mirror of
https://github.com/encounter/serverless-plugin-typescript.git
synced 2026-03-30 11:37:55 -07:00
add jest
This commit is contained in:
+16
-1
@@ -10,7 +10,8 @@
|
||||
"scripts": {
|
||||
"prepublish": "npm run build",
|
||||
"build": "rm -rf dist && tsc",
|
||||
"test": "npm run lint",
|
||||
"pretest": "npm run lint",
|
||||
"test": "jest",
|
||||
"lint": "tslint -c tslint.json 'src/**/*.ts'"
|
||||
},
|
||||
"repository": {
|
||||
@@ -25,7 +26,10 @@
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "2.0.0",
|
||||
"@types/jest": "^19.2.4",
|
||||
"@types/lodash": "^4.14.62",
|
||||
"jest": "^20.0.4",
|
||||
"ts-jest": "^20.0.6",
|
||||
"tslint": "^5.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -33,5 +37,16 @@
|
||||
"globby": "^6.1.0",
|
||||
"lodash": "^4.17.4",
|
||||
"typescript": "^2.2.2"
|
||||
},
|
||||
"jest": {
|
||||
"transform": {
|
||||
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
|
||||
},
|
||||
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
|
||||
"moduleFileExtensions": [
|
||||
"ts",
|
||||
"tsx",
|
||||
"js"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import {extractFileNames} from '../src/typescript'
|
||||
import {ServerlessFunction} from '../src/types'
|
||||
|
||||
const functions: { [key: string]: ServerlessFunction } = {
|
||||
hello: {
|
||||
handler: 'my-folder/hello.handler',
|
||||
package: {
|
||||
include: [],
|
||||
exclude: []
|
||||
}
|
||||
},
|
||||
world: {
|
||||
handler: 'my-folder/my-subfolder/world.handler',
|
||||
package: {
|
||||
include: [],
|
||||
exclude: []
|
||||
}
|
||||
},
|
||||
create: {
|
||||
handler: 'create.create',
|
||||
package: {
|
||||
include: [],
|
||||
exclude: []
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
describe('extractFileName', () => {
|
||||
it('get function filenames from serverless service', () => {
|
||||
expect(
|
||||
extractFileNames(functions),
|
||||
).toEqual(
|
||||
[
|
||||
'my-folder/hello.ts',
|
||||
'my-folder/my-subfolder/world.ts',
|
||||
'create.ts',
|
||||
],
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user