UNPKG

4.16 kBTypeScriptView Raw
1import React, { ComponentType } from 'react';
2import { API } from '@storybook/api';
3interface AssertionResult {
4 status: string;
5 fullName: string;
6 title: string;
7 failureMessages: string[];
8}
9export interface Test {
10 name: string;
11 result: {
12 status: string;
13 assertionResults: AssertionResult[];
14 };
15}
16interface InjectedProps {
17 tests?: Test[];
18}
19export interface HocProps {
20 api: API;
21 active?: boolean;
22}
23export interface HocState {
24 kind?: string;
25 storyName?: string;
26 tests?: Test[];
27}
28declare const provideTests: (Component: ComponentType<InjectedProps>) => {
29 new (props: Readonly<HocProps>): {
30 state: HocState;
31 componentDidMount(): void;
32 componentWillUnmount(): void;
33 onAddTests: ({ kind, storyName, tests }: HocState) => void;
34 mounted: boolean;
35 stopListeningOnStory: () => void;
36 render(): JSX.Element;
37 context: any;
38 setState<K extends "kind" | "storyName" | "tests">(state: HocState | ((prevState: Readonly<HocState>, props: Readonly<HocProps>) => HocState | Pick<HocState, K>) | Pick<HocState, K>, callback?: () => void): void;
39 forceUpdate(callback?: () => void): void;
40 readonly props: Readonly<HocProps> & Readonly<{
41 children?: React.ReactNode;
42 }>;
43 refs: {
44 [key: string]: React.ReactInstance;
45 };
46 shouldComponentUpdate?(nextProps: Readonly<HocProps>, nextState: Readonly<HocState>, nextContext: any): boolean;
47 componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
48 getSnapshotBeforeUpdate?(prevProps: Readonly<HocProps>, prevState: Readonly<HocState>): any;
49 componentDidUpdate?(prevProps: Readonly<HocProps>, prevState: Readonly<HocState>, snapshot?: any): void;
50 componentWillMount?(): void;
51 UNSAFE_componentWillMount?(): void;
52 componentWillReceiveProps?(nextProps: Readonly<HocProps>, nextContext: any): void;
53 UNSAFE_componentWillReceiveProps?(nextProps: Readonly<HocProps>, nextContext: any): void;
54 componentWillUpdate?(nextProps: Readonly<HocProps>, nextState: Readonly<HocState>, nextContext: any): void;
55 UNSAFE_componentWillUpdate?(nextProps: Readonly<HocProps>, nextState: Readonly<HocState>, nextContext: any): void;
56 };
57 new (props: HocProps, context?: any): {
58 state: HocState;
59 componentDidMount(): void;
60 componentWillUnmount(): void;
61 onAddTests: ({ kind, storyName, tests }: HocState) => void;
62 mounted: boolean;
63 stopListeningOnStory: () => void;
64 render(): JSX.Element;
65 context: any;
66 setState<K extends "kind" | "storyName" | "tests">(state: HocState | ((prevState: Readonly<HocState>, props: Readonly<HocProps>) => HocState | Pick<HocState, K>) | Pick<HocState, K>, callback?: () => void): void;
67 forceUpdate(callback?: () => void): void;
68 readonly props: Readonly<HocProps> & Readonly<{
69 children?: React.ReactNode;
70 }>;
71 refs: {
72 [key: string]: React.ReactInstance;
73 };
74 shouldComponentUpdate?(nextProps: Readonly<HocProps>, nextState: Readonly<HocState>, nextContext: any): boolean;
75 componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
76 getSnapshotBeforeUpdate?(prevProps: Readonly<HocProps>, prevState: Readonly<HocState>): any;
77 componentDidUpdate?(prevProps: Readonly<HocProps>, prevState: Readonly<HocState>, snapshot?: any): void;
78 componentWillMount?(): void;
79 UNSAFE_componentWillMount?(): void;
80 componentWillReceiveProps?(nextProps: Readonly<HocProps>, nextContext: any): void;
81 UNSAFE_componentWillReceiveProps?(nextProps: Readonly<HocProps>, nextContext: any): void;
82 componentWillUpdate?(nextProps: Readonly<HocProps>, nextState: Readonly<HocState>, nextContext: any): void;
83 UNSAFE_componentWillUpdate?(nextProps: Readonly<HocProps>, nextState: Readonly<HocState>, nextContext: any): void;
84 };
85 defaultProps: {
86 active: boolean;
87 };
88 contextType?: React.Context<any>;
89};
90export default provideTests;
91
\No newline at end of file