/* eslint-disable @typescript-eslint/no-explicit-any */ import React from "react"; import { Ibdd_out, ITestSpecification } from "testeranto/src/CoreTypes"; import { I } from "../react/component"; export type IProps = { foo: string, children: [] }; export type IState = { count: number }; export class MockComponent extends React.Component { constructor(props) { super(props); this.state = { count: 0 }; } render() { return (

Hello World

{JSON.stringify(this.props)}

foo: {this.props.foo}

{JSON.stringify(this.state)}

count: {this.state.count} times

); } } export default MockComponent; export type O = Ibdd_out< { Default: [string] }, // suites { AnEmptyState: [] }, // givens { // whens IClickTheButton: []; IClickTheHeader: [] }, { // thens ThePropsIs: [any]; TheStatusIs: [any]; } >; export const specification: ITestSpecification = ( Suite, Given, When, Then ) => [ Suite.Default("Testing ClassicalComponent", { "initial-state": Given.AnEmptyState( ["Component should initialize with status count zero and some props"], [], [ Then.ThePropsIs({ foo: "bar", children: [] }), Then.TheStatusIs({ count: 0 }), ] ), "button-click": Given.AnEmptyState( ["Clicking button should increment count"], [ When.IClickTheButton() ], [ Then.TheStatusIs({ count: 1 }) ] ), "header-click": Given.AnEmptyState( ["Clicking header should not change state"], [When.IClickTheHeader()], [Then.TheStatusIs({ count: 0 })] ), }), ]; export const subject = MockComponent;