Skip to content

Commit

Permalink
lets keep this synchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianGonz97 committed Jul 1, 2024
1 parent 5c45e57 commit 5b6b2bb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions packages/runed/src/lib/test/util.svelte.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { tick } from "svelte";
import { flushSync } from "svelte";
import { test, vi } from "vitest";

export function testWithEffect(name: string, fn: () => void | Promise<void>) {
Expand All @@ -24,9 +24,8 @@ export function vitestSetTimeoutWrapper(fn: () => void, timeout: number) {
vi.advanceTimersByTime(timeout);
}

export async function focus(node: HTMLElement | null | undefined) {
export function focus(node: HTMLElement | null | undefined) {
if (node) {
node.focus();
await tick();
flushSync(() => node.focus());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("IsFocusWithin", () => {
expect(current).toHaveTextContent("false");
await user.click(input);
expect(current).toHaveTextContent("true");
await focus(submit);
focus(submit);
expect(submit).toHaveFocus();
expect(current).toHaveTextContent("true");
});
Expand All @@ -42,7 +42,7 @@ describe("IsFocusWithin", () => {
const { user, input, current, outside } = setup();
await user.click(input);
expect(current).toHaveTextContent("true");
await focus(outside);
focus(outside);
expect(outside).toHaveFocus();
expect(current).toHaveTextContent("false");
});
Expand Down

0 comments on commit 5b6b2bb

Please sign in to comment.