|
| 1 | +import path from 'path'; |
| 2 | +import test from 'ava'; |
| 3 | +import {verify} from './fixtures/utils'; |
| 4 | +import tsd from '..'; |
| 5 | + |
| 6 | +test('print type', async t => { |
| 7 | + const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/informational/print-type')}); |
| 8 | + |
| 9 | + verify(t, diagnostics, [ |
| 10 | + [4, 0, 'warning', 'Type for expression `aboveZero` is: `(foo: number) => number | null`'], |
| 11 | + [5, 0, 'warning', 'Type for expression `null` is: `null`'], |
| 12 | + [6, 0, 'warning', 'Type for expression `undefined` is: `undefined`'], |
| 13 | + [7, 0, 'warning', 'Type for expression `null as any` is: `any`'], |
| 14 | + [8, 0, 'warning', 'Type for expression `null as never` is: `never`'], |
| 15 | + [9, 0, 'warning', 'Type for expression `null as unknown` is: `unknown`'], |
| 16 | + [10, 0, 'warning', 'Type for expression `\'foo\'` is: `"foo"`'], |
| 17 | + [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; }`'], |
| 18 | + ]); |
| 19 | +}); |
| 20 | + |
| 21 | +test('expect doc comment includes', async t => { |
| 22 | + const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/informational/expect-doc-comment')}); |
| 23 | + |
| 24 | + verify(t, diagnostics, [ |
| 25 | + [5, 0, 'error', 'Documentation comment for expression `noDocComment` not found.'], |
| 26 | + [10, 0, 'error', 'Expected documentation comment for expression `foo` not specified.'], |
| 27 | + [11, 0, 'error', 'Expected documentation comment for expression `foo` should be a string literal.'], |
| 28 | + [12, 0, 'error', 'Documentation comment `FooBar` for expression `foo` does not include expected `BarFoo`.'], |
| 29 | + ]); |
| 30 | +}); |
0 commit comments