Skip to content

Commit

Permalink
fix: use the correct flush
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Aug 12, 2024
1 parent 43bc774 commit 95c3e3c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions packages/schema-zod/src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fireEvent, render, screen } from '@testing-library/vue';
import { useForm, useTextField } from '@formwerk/core';
import { defineSchema } from '.';
import { z } from 'zod';
import flush from 'flush-promises';
import { flush } from '@test-utils/index';

describe('schema-zod', () => {
function createInputComponent(): Component {
Expand Down Expand Up @@ -46,8 +46,6 @@ describe('schema-zod', () => {
`,
});

await flush();
vi.advanceTimersByTime(1000);
await flush();
expect(screen.getByTestId('form-valid').textContent).toBe('false');
expect(screen.getByTestId('err').textContent).toBe('Required');
Expand Down Expand Up @@ -192,8 +190,6 @@ describe('schema-zod', () => {
`,
});

await flush();
vi.advanceTimersByTime(1000);
await flush();
expect(screen.getByTestId('is-valid').textContent).toBe('false');
expect(screen.getByTestId('e1').textContent).toBe('Required');
Expand All @@ -203,7 +199,6 @@ describe('schema-zod', () => {
await fireEvent.update(screen.getByTestId('some.array.0.path'), 'test');
await fireEvent.blur(screen.getByTestId('some.deep.path'));
await fireEvent.blur(screen.getByTestId('some.array.0.path'));
vi.advanceTimersByTime(1000);
await flush();
expect(screen.getByTestId('is-valid').textContent).toBe('true');
expect(screen.getByTestId('e1').textContent).toBe('');
Expand Down
2 changes: 1 addition & 1 deletion packages/test-utils/src/flush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import { vi } from 'vitest';

export async function flush() {
await flushPromises();
vi.advanceTimersByTime(SCHEMA_BATCH_MS + 10);
vi.advanceTimersByTime(SCHEMA_BATCH_MS * 2);
await flushPromises();
}

0 comments on commit 95c3e3c

Please sign in to comment.