Skip to content

Commit 5c76e4f

Browse files
committed
Update matcher to allow ProfiledComponent as acceptable value
1 parent 01d6696 commit 5c76e4f

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/testing/matchers/ProfiledComponent.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ import { WaitForRenderTimeoutError } from "../internal/index.js";
33
import type {
44
NextRenderOptions,
55
Profiler,
6+
ProfiledComponent,
67
ProfiledHook,
78
} from "../internal/index.js";
89

910
export const toRerender: MatcherFunction<[options?: NextRenderOptions]> =
1011
async function (actual, options) {
11-
const _profiler = actual as Profiler<any> | ProfiledHook<any, any>;
12+
const _profiler = actual as
13+
| Profiler<any>
14+
| ProfiledComponent<any, any>
15+
| ProfiledHook<any, any>;
1216
const profiler = "Profiler" in _profiler ? _profiler.Profiler : _profiler;
1317
const hint = this.utils.matcherHint("toRerender", "ProfiledComponent", "");
1418
let pass = true;
@@ -40,7 +44,10 @@ const failed = {};
4044
export const toRenderExactlyTimes: MatcherFunction<
4145
[times: number, options?: NextRenderOptions]
4246
> = async function (actual, times, optionsPerRender) {
43-
const _profiler = actual as Profiler<any> | ProfiledHook<any, any>;
47+
const _profiler = actual as
48+
| Profiler<any>
49+
| ProfiledComponent<any, any>
50+
| ProfiledHook<any, any>;
4451
const profiler = "Profiler" in _profiler ? _profiler.Profiler : _profiler;
4552
const options = { timeout: 100, ...optionsPerRender };
4653
const hint = this.utils.matcherHint("toRenderExactlyTimes");

src/testing/matchers/index.d.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
import {
77
NextRenderOptions,
88
Profiler,
9+
ProfiledComponent,
910
ProfiledHook,
1011
} from "../internal/index.js";
1112

@@ -29,11 +30,17 @@ interface ApolloCustomMatchers<R = void, T = {}> {
2930
) => R
3031
: { error: "matcher needs to be called on an ApolloClient instance" };
3132

32-
toRerender: T extends Profiler<any, any> | ProfiledHook<any, any>
33+
toRerender: T extends
34+
| Profiler<any, any>
35+
| ProfiledComponent<any, any>
36+
| ProfiledHook<any, any>
3337
? (options?: NextRenderOptions) => Promise<R>
3438
: { error: "matcher needs to be called on a ProfiledComponent instance" };
3539

36-
toRenderExactlyTimes: T extends Profiler<any, any> | ProfiledHook<any, any>
40+
toRenderExactlyTimes: T extends
41+
| Profiler<any, any>
42+
| ProfiledComponent<any, any>
43+
| ProfiledHook<any, any>
3744
? (count: number, options?: NextRenderOptions) => Promise<R>
3845
: { error: "matcher needs to be called on a ProfiledComponent instance" };
3946
}

0 commit comments

Comments
 (0)