Move automatic media actions out of carousels
This commit is contained in:
+27
-2
@@ -385,13 +385,20 @@ export const requestAnimationFrameMock = (callback: FrameRequestCallback) => {
|
||||
return 1;
|
||||
};
|
||||
|
||||
export const callIntersectionHandler = (intersecting = true, n = 0): void => {
|
||||
export const callIntersectionHandler = async (
|
||||
intersecting = true,
|
||||
n = 0,
|
||||
): Promise<void> => {
|
||||
const mockResult = vi.mocked(IntersectionObserver).mock.results[n];
|
||||
if (mockResult.type !== 'return') {
|
||||
return;
|
||||
}
|
||||
const observer = mockResult.value;
|
||||
vi.mocked(IntersectionObserver).mock.calls[n][0](
|
||||
await (
|
||||
vi.mocked(IntersectionObserver).mock.calls[n][0] as
|
||||
| IntersectionObserverCallback
|
||||
| ((_: unknown) => Promise<void>)
|
||||
)(
|
||||
// Note this is a very incomplete / invalid IntersectionObserverEntry that
|
||||
// just provides the bare basics current implementation uses.
|
||||
intersecting ? [{ isIntersecting: true } as IntersectionObserverEntry] : [],
|
||||
@@ -399,6 +406,24 @@ export const callIntersectionHandler = (intersecting = true, n = 0): void => {
|
||||
);
|
||||
};
|
||||
|
||||
export const callMutationHandler = async (n = 0): Promise<void> => {
|
||||
const mockResult = vi.mocked(MutationObserver).mock.results[n];
|
||||
if (mockResult.type !== 'return') {
|
||||
return;
|
||||
}
|
||||
const observer = mockResult.value;
|
||||
await (
|
||||
vi.mocked(MutationObserver).mock.calls[n][0] as
|
||||
| MutationCallback
|
||||
| ((_: unknown) => Promise<void>)
|
||||
)(
|
||||
// Note this is a very incomplete / invalid IntersectionObserverEntry that
|
||||
// just provides the bare basics current implementation uses.
|
||||
[],
|
||||
observer,
|
||||
);
|
||||
};
|
||||
|
||||
export const createSlotHost = (options?: {
|
||||
slot?: HTMLSlotElement;
|
||||
children?: HTMLElement[];
|
||||
|
||||
Reference in New Issue
Block a user