-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
roman.vasilev
committed
Jun 30, 2018
1 parent
7f31a56
commit 84857f7
Showing
10 changed files
with
116 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import * as assert from 'assert'; | ||
import * as lib from './index'; | ||
|
||
let service: ReturnType<typeof lib.createService>; | ||
|
||
it('smoke', () => { | ||
assert(lib); | ||
}); | ||
|
||
describe('create service', () => { | ||
|
||
before(() => { | ||
const configFile = `${__dirname}/test-project/tsconfig.json`; | ||
service = lib.createService({ configFile }); | ||
assert(service); | ||
}); | ||
|
||
it('errors', () => { | ||
const testFile = `${__dirname}/test-project/errors.ts`; | ||
service.update({ fileName: testFile }); | ||
const sourceFile = service.getProgram().getSourceFile(testFile); | ||
assert(sourceFile); | ||
const diagnostics = service.getDiagnostics(testFile); | ||
assert.equal(diagnostics.length, 2); | ||
assert.equal(diagnostics[0].messageText, `Type '1' is not assignable to type 'string'.`); | ||
assert.equal(diagnostics[1].messageText, `Type '"foo"' is not assignable to type 'number'.`); | ||
}); | ||
|
||
it('number', () => { | ||
const testFile = `${__dirname}/test-project/number.ts`; | ||
service.update({ fileName: testFile }); | ||
const sourceFile = service.getProgram().getSourceFile(testFile); | ||
assert(sourceFile); | ||
const diagnostics = service.getDiagnostics(testFile); | ||
assert.equal(diagnostics.length, 0); | ||
}); | ||
|
||
it('built in', () => { | ||
const testFile = `${__dirname}/test-project/builtin.ts`; | ||
service.update({ fileName: testFile }); | ||
const sourceFile = service.getProgram().getSourceFile(testFile); | ||
assert(sourceFile); | ||
const diagnostics = service.getDiagnostics(testFile); | ||
assert.equal(diagnostics.length, 0); | ||
}); | ||
|
||
it('types', () => { | ||
const testFile = `${__dirname}/test-project/types.ts`; | ||
service.update({ fileName: testFile }); | ||
const sourceFile = service.getProgram().getSourceFile(testFile); | ||
assert(sourceFile); | ||
const diagnostics = service.getDiagnostics(testFile); | ||
assert.equal(diagnostics.length, 0); | ||
}); | ||
|
||
it('decorator', () => { | ||
const testFile = `${__dirname}/test-project/decorator.ts`; | ||
service.update({ fileName: testFile }); | ||
const sourceFile = service.getProgram().getSourceFile(testFile); | ||
assert(sourceFile); | ||
const diagnostics = service.getDiagnostics(testFile); | ||
assert.equal(diagnostics.length, 0); | ||
}); | ||
|
||
it('global types', () => { | ||
const testFile = `${__dirname}/test-project/global-types.ts`; | ||
service.update({ fileName: testFile }); | ||
const sourceFile = service.getProgram().getSourceFile(testFile); | ||
assert(sourceFile); | ||
const diagnostics = service.getDiagnostics(testFile); | ||
assert.equal(diagnostics.length, 0); | ||
}); | ||
|
||
it('date', () => { | ||
const testFile = `${__dirname}/test-project/date.ts`; | ||
service.update({ fileName: testFile }); | ||
const sourceFile = service.getProgram().getSourceFile(testFile); | ||
assert(sourceFile); | ||
const diagnostics = service.getDiagnostics(testFile); | ||
assert.equal(diagnostics.length, 0); | ||
}); | ||
|
||
}); | ||
|
||
it('create service no libs', () => { | ||
const configFile = `${__dirname}/test-project/tsconfig-nolibs.json`; | ||
service = lib.createService({ configFile }); | ||
assert(service); | ||
}); |
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 @@ | ||
console.log(window, Promise, Date, Function); |
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 @@ | ||
console.log(Date); |
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,2 @@ | ||
declare const deco: any; | ||
@deco() class Target {} |
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,3 @@ | ||
import * as number from './number'; | ||
const a: string = 1; | ||
const foo: number = 'foo'; |
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 @@ | ||
typeof process.env |
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 @@ | ||
export const n: number = 1; |
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,6 @@ | ||
{ | ||
"compilerOptions": { | ||
"moduleResolution": "node", | ||
"strict": true, | ||
} | ||
} |
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,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"importHelpers": true, | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"experimentalDecorators": true, | ||
"strict": true, | ||
"lib": ["es2017", "dom"] | ||
} | ||
} |
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 @@ | ||
import * as lib from 'mocha'; |