Add package for ink-testing-library (#33842)

This commit is contained in:
Sam Palmer
2019-03-13 10:27:46 -07:00
committed by Wesley Wigham
parent 5ab3d68377
commit 85883977ef
4 changed files with 68 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
// Type definitions for ink-testing-library 1.0
// Project: https://github.com/vadimdemedes/ink-testing-library#readme
// Definitions by: Sam Palmer <https://github.com/MancunianSam>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.9
import { Component, InkElement } from "ink";
export interface RenderResponse {
rerender: (tree: InkElement) => void;
unmount: () => void;
stdin: {
write: (data: any) => boolean;
};
frames: ReadonlyArray<string>;
lastFrame: () => string;
}
export function cleanup(): void;
export function render(tree: InkElement): RenderResponse;
@@ -0,0 +1,24 @@
/** @jsx h */
import { render, RenderResponse, cleanup } from "ink-testing-library";
import { Component, h } from "ink";
const renderResponse = render(<Component<{}, {}, {}> />); // $ExpectType RenderResponse
renderResponse.frames; // $ExpectType ReadonlyArray<string>
const rerender = renderResponse.rerender; // $ExpectType (tree: InkElement) => void
rerender(<Component<{}, {}, {}> />); // $ExpectType void
const unmount = renderResponse.unmount; // $ExpectType () => void
unmount(); // $ExpectType void
const stdin = renderResponse.stdin; // $ExpectType { write: (data: any) => boolean; }
stdin.write(""); // $ExpectType boolean
stdin.write([]); // $ExpectType boolean
stdin.write({}); // $ExpectType boolean
const lastFrame = renderResponse.lastFrame; // $ExpectType () => string
lastFrame(); // $ExpectType string
cleanup; // $ExpectType () => void
cleanup(); // $ExpectType void
+25
View File
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"jsx": "react",
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"strictFunctionTypes": true
},
"files": [
"index.d.ts",
"ink-testing-library-tests.tsx"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }