File tree Expand file tree Collapse file tree 3 files changed +2169
-20
lines changed Expand file tree Collapse file tree 3 files changed +2169
-20
lines changed Original file line number Diff line number Diff line change 10
10
"scripts" : {
11
11
"prepublish" : " npm run build" ,
12
12
"build" : " rm -rf dist && tsc" ,
13
- "test" : " npm run lint" ,
13
+ "pretest" : " npm run lint" ,
14
+ "test" : " jest" ,
14
15
"lint" : " tslint -c tslint.json 'src/**/*.ts'"
15
16
},
16
17
"repository" : {
25
26
],
26
27
"devDependencies" : {
27
28
"@types/fs-extra" : " 2.0.0" ,
29
+ "@types/jest" : " ^19.2.4" ,
28
30
"@types/lodash" : " ^4.14.62" ,
31
+ "jest" : " ^20.0.4" ,
32
+ "ts-jest" : " ^20.0.6" ,
29
33
"tslint" : " ^5.1.0"
30
34
},
31
35
"dependencies" : {
32
36
"fs-p" : " 2.0.0" ,
33
37
"globby" : " ^6.1.0" ,
34
38
"lodash" : " ^4.17.4" ,
35
39
"typescript" : " ^2.2.2"
40
+ },
41
+ "jest" : {
42
+ "transform" : {
43
+ ".(ts|tsx)" : " <rootDir>/node_modules/ts-jest/preprocessor.js"
44
+ },
45
+ "testRegex" : " (/__tests__/.*|\\ .(test|spec))\\ .(ts|tsx|js)$" ,
46
+ "moduleFileExtensions" : [
47
+ " ts" ,
48
+ " tsx" ,
49
+ " js"
50
+ ]
36
51
}
37
52
}
Original file line number Diff line number Diff line change
1
+ import { extractFileNames } from '../src/typescript'
2
+ import { ServerlessFunction } from '../src/types'
3
+
4
+ const functions : { [ key : string ] : ServerlessFunction } = {
5
+ hello : {
6
+ handler : 'my-folder/hello.handler' ,
7
+ package : {
8
+ include : [ ] ,
9
+ exclude : [ ]
10
+ }
11
+ } ,
12
+ world : {
13
+ handler : 'my-folder/my-subfolder/world.handler' ,
14
+ package : {
15
+ include : [ ] ,
16
+ exclude : [ ]
17
+ }
18
+ } ,
19
+ create : {
20
+ handler : 'create.create' ,
21
+ package : {
22
+ include : [ ] ,
23
+ exclude : [ ]
24
+ }
25
+ } ,
26
+ }
27
+
28
+ describe ( 'extractFileName' , ( ) => {
29
+ it ( 'get function filenames from serverless service' , ( ) => {
30
+ expect (
31
+ extractFileNames ( functions ) ,
32
+ ) . toEqual (
33
+ [
34
+ 'my-folder/hello.ts' ,
35
+ 'my-folder/my-subfolder/world.ts' ,
36
+ 'create.ts' ,
37
+ ] ,
38
+ )
39
+ } )
40
+ } )
41
+
You can’t perform that action at this time.
0 commit comments