-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
expectDocCommentIncludes
assertion (#155)
- Loading branch information
1 parent
68acb5b
commit c3d0949
Showing
16 changed files
with
159 additions
and
32 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
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
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
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
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
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
1 change: 1 addition & 0 deletions
1
source/test/fixtures/informational/expect-doc-comment/index.d.ts
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 default function (foo: number): number | null; |
File renamed without changes.
15 changes: 15 additions & 0 deletions
15
source/test/fixtures/informational/expect-doc-comment/index.test-d.ts
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,15 @@ | ||
import {expectDocCommentIncludes} from '../../../..'; | ||
|
||
const noDocComment = 'no doc comment'; | ||
|
||
expectDocCommentIncludes<'no doc comment'>(noDocComment); | ||
|
||
/** FooBar */ | ||
const foo = 'bar'; | ||
|
||
expectDocCommentIncludes(foo); | ||
expectDocCommentIncludes<boolean>(foo); | ||
expectDocCommentIncludes<'BarFoo'>(foo); | ||
expectDocCommentIncludes<'FooBar'>(foo); | ||
expectDocCommentIncludes<'Foo'>(foo); | ||
expectDocCommentIncludes<'Bar'>(foo); |
File renamed without changes.
File renamed without changes.
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 @@ | ||
module.exports.default = foo => { | ||
return foo > 0 ? foo : null; | ||
}; |
2 changes: 1 addition & 1 deletion
2
.../test/fixtures/print-type/index.test-d.ts → .../informational/print-type/index.test-d.ts
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
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 @@ | ||
{ | ||
"name": "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,30 @@ | ||
import path from 'path'; | ||
import test from 'ava'; | ||
import {verify} from './fixtures/utils'; | ||
import tsd from '..'; | ||
|
||
test('print type', async t => { | ||
const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/informational/print-type')}); | ||
|
||
verify(t, diagnostics, [ | ||
[4, 0, 'warning', 'Type for expression `aboveZero` is: `(foo: number) => number | null`'], | ||
[5, 0, 'warning', 'Type for expression `null` is: `null`'], | ||
[6, 0, 'warning', 'Type for expression `undefined` is: `undefined`'], | ||
[7, 0, 'warning', 'Type for expression `null as any` is: `any`'], | ||
[8, 0, 'warning', 'Type for expression `null as never` is: `never`'], | ||
[9, 0, 'warning', 'Type for expression `null as unknown` is: `unknown`'], | ||
[10, 0, 'warning', 'Type for expression `\'foo\'` is: `"foo"`'], | ||
[11, 0, 'warning', 'Type for expression `bigType` is: `{ prop1: SuperTypeWithAnExessiveLongNameThatTakesUpTooMuchSpace; prop2: SuperTypeWithAnExessiveLongNameThatTakesUpTooMuchSpace; prop3: SuperTypeWithAnExessiveLongNameThatTakesUpTooMuchSpace; prop4: SuperTypeWithAnExessiveLongNameThatTakesUpTooMuchSpace; prop5: SuperTypeWithAnExessiveLongNameThatTakesUpTooMuchSpace; prop6: SuperTypeWithAnExessiveLongNameThatTakesUpTooMuchSpace; prop7: SuperTypeWithAnExessiveLongNameThatTakesUpTooMuchSpace; prop8: SuperTypeWithAnExessiveLongNameThatTakesUpTooMuchSpace; prop9: SuperTypeWithAnExessiveLongNameThatTakesUpTooMuchSpace; }`'], | ||
]); | ||
}); | ||
|
||
test('expect doc comment includes', async t => { | ||
const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/informational/expect-doc-comment')}); | ||
|
||
verify(t, diagnostics, [ | ||
[5, 0, 'error', 'Documentation comment for expression `noDocComment` not found.'], | ||
[10, 0, 'error', 'Expected documentation comment for expression `foo` not specified.'], | ||
[11, 0, 'error', 'Expected documentation comment for expression `foo` should be a string literal.'], | ||
[12, 0, 'error', 'Documentation comment `FooBar` for expression `foo` does not include expected `BarFoo`.'], | ||
]); | ||
}); |
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