Skip to content

Commit ce834c1

Browse files
committed
Fixed tests to include both custom and html callback
1 parent 94d61d7 commit ce834c1

File tree

11 files changed

+23
-23
lines changed

11 files changed

+23
-23
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ it("Child callback causes click count to increase", async () => {
4242
await act(() =>
4343
getMockComponentPropCalls(Child)
4444
?.at(-1)
45-
?.onClick?.({} as any)
45+
?.onComplicatedCallback?.({} as any)
4646
);
4747

4848
// Assert

src/tests-class-component/child-with-children/test-asset.child.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import React, { HtmlHTMLAttributes } from "react";
22

3-
export type ChildProps = React.PropsWithChildren<
4-
Pick<HtmlHTMLAttributes<HTMLButtonElement>, "onClick"> & {
5-
someData: string;
6-
onPointerEnter: () => void;
7-
}
8-
>;
3+
export type ChildProps = React.PropsWithChildren<{
4+
onClick: HtmlHTMLAttributes<HTMLButtonElement>["onClick"];
5+
someData: string;
6+
onComplicatedCallback: () => void;
7+
}>;
98

109
export class Child extends React.Component<ChildProps> {
1110
render() {

src/tests-class-component/child-with-children/test-asset.parent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class Parent extends React.Component<ParentProps, ParentState> {
4040
data-testid={parentTestIdMap.child}
4141
onClick={this.handleChildClick}
4242
someData="someData"
43-
onPointerEnter={() => {}}
43+
onComplicatedCallback={() => {}}
4444
>
4545
Increment
4646
</Child>

src/tests-class-component/child-with-props/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe("Github issue #7 - Using ReturnType on createMockComponent", () => {
4040
it("Renders dynamic import child", async () => {
4141
// Arrange
4242
const spy = jest.fn();
43-
const result = render(<Child onClick={spy} someData="someData" onPointerEnter={() => {}} />);
43+
const result = render(<Child onClick={spy} someData="someData" onComplicatedCallback={() => {}} />);
4444

4545
// Act
4646
await userEvent.click(result.getByRole("button"));

src/tests-class-component/child-with-props/test-asset.child.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React, { HtmlHTMLAttributes } from "react";
22

3-
export type ChildProps = Pick<HtmlHTMLAttributes<HTMLButtonElement>, "onClick"> & {
3+
export type ChildProps = {
4+
onClick: HtmlHTMLAttributes<HTMLButtonElement>["onClick"];
45
someData: string;
5-
onPointerEnter: () => void;
6+
onComplicatedCallback: () => void;
67
};
78

89
export class Child extends React.Component<ChildProps> {

src/tests-class-component/child-with-props/test-asset.parent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class Parent extends React.Component<ParentProps, ParentState> {
4040
data-testid={parentTestIdMap.child}
4141
onClick={this.handleChildClick}
4242
someData="someData"
43-
onPointerEnter={() => {}}
43+
onComplicatedCallback={() => {}}
4444
/>
4545
</div>
4646
);

src/tests-functional-component/child-with-children/test-asset.child.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import React, { HtmlHTMLAttributes } from "react";
22

3-
export type ChildProps = React.PropsWithChildren<
4-
Pick<HtmlHTMLAttributes<HTMLButtonElement>, "onClick"> & {
5-
someData: string;
6-
onPointerEnter: () => void;
7-
}
8-
>;
3+
export type ChildProps = React.PropsWithChildren<{
4+
onClick: HtmlHTMLAttributes<HTMLButtonElement>["onClick"];
5+
someData: string;
6+
onComplicatedCallback: () => void;
7+
}>;
98

109
export function Child(props: ChildProps) {
1110
const { onClick, children } = props;

src/tests-functional-component/child-with-children/test-asset.parent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function Parent(props: ParentProps) {
2525
data-testid={parentTestIdMap.child}
2626
onClick={handleChildClick}
2727
someData="someData"
28-
onPointerEnter={() => {}}
28+
onComplicatedCallback={() => {}}
2929
>
3030
Increment
3131
</Child>

src/tests-functional-component/child-with-props/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe("Github issue #7 - Using ReturnType on createMockComponent", () => {
4040
it("Renders dynamic import child", async () => {
4141
// Arrange
4242
const spy = jest.fn();
43-
const result = render(<Child onClick={spy} someData="someData" onPointerEnter={() => {}} />);
43+
const result = render(<Child onClick={spy} someData="someData" onComplicatedCallback={() => {}} />);
4444

4545
// Act
4646
await userEvent.click(result.getByRole("button"));

src/tests-functional-component/child-with-props/test-asset.child.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React, { HtmlHTMLAttributes } from "react";
22

3-
export type ChildProps = Pick<HtmlHTMLAttributes<HTMLButtonElement>, "onClick"> & {
3+
export type ChildProps = {
4+
onClick: HtmlHTMLAttributes<HTMLButtonElement>["onClick"];
45
someData: string;
5-
onPointerEnter: () => void;
6+
onComplicatedCallback: () => void;
67
};
78

89
export function Child(props: ChildProps) {

0 commit comments

Comments
 (0)