Skip to content

Commit d1019ac

Browse files
committed
add other tests
1 parent 4f9aa5d commit d1019ac

File tree

3 files changed

+53
-15
lines changed

3 files changed

+53
-15
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
"README.md"
88
],
99
"scripts": {
10-
"prepublish": "npm run build",
10+
"prepublish": "npm run test",
1111
"build": "rm -rf dist && tsc",
12-
"test": "npm run lint",
12+
"pretest": "npm run lint",
13+
"test": "jest",
1314
"lint": "tslint -c tslint.json 'src/**/*.ts'"
1415
},
1516
"devDependencies": {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`typescript modules getTypescriptConfig get configurations from tsconfig.json 1`] = `
4+
Object {
5+
"lib": Array [
6+
"lib.es2015.d.ts",
7+
],
8+
"moduleResolution": 2,
9+
"preserveConstEnums": true,
10+
"sourceMap": true,
11+
"strictNullChecks": true,
12+
"target": 1,
13+
}
14+
`;

tests/typescript.test.ts

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import {extractFileNames} from '../src/typescript'
1+
import {extractFileNames, getTypescriptConfig, run} from '../src/typescript'
2+
import * as path from 'path'
3+
4+
const ROOT_PATH = path.resolve(__dirname)
25

36
const functions = {
47
hello: {
@@ -12,17 +15,37 @@ const functions = {
1215
},
1316
}
1417

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-
)
18+
describe('typescript modules', () => {
19+
describe('extractFileName', () => {
20+
21+
it('get function filenames from serverless service', () => {
22+
expect(
23+
extractFileNames(functions),
24+
).toEqual(
25+
[
26+
'my-folder/hello.ts',
27+
'my-folder/my-subfolder/world.ts',
28+
'create.ts',
29+
],
30+
)
31+
})
2632
})
27-
})
2833

34+
describe('getTypescriptConfig', () => {
35+
it('get configurations from tsconfig.json', () => {
36+
expect(
37+
getTypescriptConfig(ROOT_PATH)
38+
).toMatchSnapshot()
39+
})
40+
})
41+
42+
// describe('run', () => {
43+
// it('compile files to ts', () => {
44+
// const fileNames = extractFileNames(functions)
45+
// const config = getTypescriptConfig(ROOT_PATH)
46+
// expect(
47+
// run(fileNames, config)
48+
// ).toBe(false)
49+
// })
50+
// })
51+
})

0 commit comments

Comments
 (0)