mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
Add package for ink-testing-library (#33842)
This commit is contained in:
committed by
Wesley Wigham
parent
5ab3d68377
commit
85883977ef
Vendored
+18
@@ -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
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user