Skip to content

Commit 4f9aa5d

Browse files
committed
add jest and typescript.ts tests
1 parent 3e34d9b commit 4f9aa5d

File tree

4 files changed

+3061
-101
lines changed

4 files changed

+3061
-101
lines changed

package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,28 @@
1414
},
1515
"devDependencies": {
1616
"@types/fs-extra": "^2.0.0",
17+
"@types/jest": "^19.2.2",
1718
"@types/lodash": "^4.14.62",
19+
"jest": "^19.0.2",
20+
"serverless": "^1.11.0",
21+
"ts-jest": "^19.0.10",
1822
"tslint": "^5.1.0"
1923
},
2024
"dependencies": {
2125
"fs-p": "^2.0.0",
2226
"lodash": "^4.17.4",
2327
"typescript": "^2.2.2"
28+
},
29+
"jest": {
30+
"transform": {
31+
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
32+
},
33+
"testResultsProcessor": "<rootDir>/node_modules/ts-jest/coverageprocessor.js",
34+
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
35+
"moduleFileExtensions": [
36+
"ts",
37+
"tsx",
38+
"js"
39+
]
2440
}
2541
}

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface ServerlessOptions {
1717

1818
export interface ServerlessFunction {
1919
handler: string
20-
package: ServerlessPackage
20+
package?: ServerlessPackage
2121
}
2222

2323
export interface ServerlessPackage {

tests/typescript.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import {extractFileNames} from '../src/typescript'
2+
3+
const functions = {
4+
hello: {
5+
handler: 'my-folder/hello.handler',
6+
},
7+
world: {
8+
handler: 'my-folder/my-subfolder/world.handler',
9+
},
10+
create: {
11+
handler: 'create.create',
12+
},
13+
}
14+
15+
describe('extractFileName', () => {
16+
it('get function filenames from serverless service', () => {
17+
expect(
18+
extractFileNames(functions),
19+
).toEqual(
20+
[
21+
'my-folder/hello.ts',
22+
'my-folder/my-subfolder/world.ts',
23+
'create.ts',
24+
],
25+
)
26+
})
27+
})
28+

0 commit comments

Comments
 (0)