From c1b7778a3f3b5b917baa922f2c84218fac855eb0 Mon Sep 17 00:00:00 2001 From: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com> Date: Wed, 17 Jul 2024 23:34:50 +1000 Subject: [PATCH] Fix svelte-query-persist-client tests --- .../tests/FreshData/FreshData.svelte | 6 ++---- .../tests/FreshData/Provider.svelte | 5 ++--- .../tests/InitialData/InitialData.svelte | 12 +++--------- .../tests/InitialData/Provider.svelte | 3 +-- .../tests/OnSuccess/OnSuccess.svelte | 4 ++-- .../tests/OnSuccess/Provider.svelte | 3 +-- .../PersistQueryClientProvider.svelte.test.ts | 4 ++-- .../tests/RemoveCache/Provider.svelte | 3 +-- .../tests/RemoveCache/RemoveCache.svelte | 4 ++-- .../tests/RestoreCache/Provider.svelte | 3 +-- .../tests/RestoreCache/RestoreCache.svelte | 12 +++--------- .../tests/UseQueries/Provider.svelte | 3 +-- .../tests/UseQueries/UseQueries.svelte | 14 ++++---------- .../tests/createInfiniteQuery/BaseExample.svelte | 2 +- 14 files changed, 26 insertions(+), 52 deletions(-) diff --git a/packages/svelte-query-persist-client/tests/FreshData/FreshData.svelte b/packages/svelte-query-persist-client/tests/FreshData/FreshData.svelte index 7c8d7d9a6e..859a67e4b6 100644 --- a/packages/svelte-query-persist-client/tests/FreshData/FreshData.svelte +++ b/packages/svelte-query-persist-client/tests/FreshData/FreshData.svelte @@ -5,10 +5,8 @@ import type { StatusResult } from '../utils.svelte' let { - key, states, }: { - key: Array states: { value: Array> } fetched: boolean } = $props() @@ -29,5 +27,5 @@ }) -
data: {$query.data ?? 'null'}
-
fetchStatus: {$query.fetchStatus}
+
data: {query.data ?? 'undefined'}
+
fetchStatus: {query.fetchStatus}
diff --git a/packages/svelte-query-persist-client/tests/FreshData/Provider.svelte b/packages/svelte-query-persist-client/tests/FreshData/Provider.svelte index 657b1aea3f..eb52193738 100644 --- a/packages/svelte-query-persist-client/tests/FreshData/Provider.svelte +++ b/packages/svelte-query-persist-client/tests/FreshData/Provider.svelte @@ -8,14 +8,13 @@ interface Props { queryClient: QueryClient persistOptions: OmitKeyof - key: Array states: { value: Array> } fetched: boolean } - let { queryClient, persistOptions, key, states, fetched }: Props = $props() + let { queryClient, persistOptions, states, fetched }: Props = $props() - + diff --git a/packages/svelte-query-persist-client/tests/InitialData/InitialData.svelte b/packages/svelte-query-persist-client/tests/InitialData/InitialData.svelte index 68d936293c..e97e82ffd7 100644 --- a/packages/svelte-query-persist-client/tests/InitialData/InitialData.svelte +++ b/packages/svelte-query-persist-client/tests/InitialData/InitialData.svelte @@ -4,13 +4,7 @@ import { sleep } from '../utils.svelte' import type { StatusResult } from '../utils.svelte' - let { - key, - states, - }: { - key: Array - states: { value: Array> } - } = $props() + let { states }: { states: { value: Array> } } = $props() const query = createQuery({ queryKey: ['test'], @@ -30,5 +24,5 @@ }) -
{$query.data}
-
fetchStatus: {$query.fetchStatus}
+
{query.data}
+
fetchStatus: {query.fetchStatus}
diff --git a/packages/svelte-query-persist-client/tests/InitialData/Provider.svelte b/packages/svelte-query-persist-client/tests/InitialData/Provider.svelte index e351d1cc62..d18b79aea3 100644 --- a/packages/svelte-query-persist-client/tests/InitialData/Provider.svelte +++ b/packages/svelte-query-persist-client/tests/InitialData/Provider.svelte @@ -8,11 +8,10 @@ interface Props { queryClient: QueryClient persistOptions: OmitKeyof - key: Array states: { value: Array> } } - let { queryClient, persistOptions, key, states }: Props = $props() + let { queryClient, persistOptions, states }: Props = $props() diff --git a/packages/svelte-query-persist-client/tests/OnSuccess/OnSuccess.svelte b/packages/svelte-query-persist-client/tests/OnSuccess/OnSuccess.svelte index 88f3a90eec..6aef3be046 100644 --- a/packages/svelte-query-persist-client/tests/OnSuccess/OnSuccess.svelte +++ b/packages/svelte-query-persist-client/tests/OnSuccess/OnSuccess.svelte @@ -11,5 +11,5 @@ }) -
{$query.data}
-
fetchStatus: {$query.fetchStatus}
+
{query.data}
+
fetchStatus: {query.fetchStatus}
diff --git a/packages/svelte-query-persist-client/tests/OnSuccess/Provider.svelte b/packages/svelte-query-persist-client/tests/OnSuccess/Provider.svelte index 0655c601a2..0b280ca570 100644 --- a/packages/svelte-query-persist-client/tests/OnSuccess/Provider.svelte +++ b/packages/svelte-query-persist-client/tests/OnSuccess/Provider.svelte @@ -7,11 +7,10 @@ interface Props { queryClient: QueryClient persistOptions: OmitKeyof - key: Array onSuccess: () => void } - let { queryClient, persistOptions, key, onSuccess }: Props = $props() + let { queryClient, persistOptions, onSuccess }: Props = $props() diff --git a/packages/svelte-query-persist-client/tests/PersistQueryClientProvider.svelte.test.ts b/packages/svelte-query-persist-client/tests/PersistQueryClientProvider.svelte.test.ts index 8a78dd6c57..c4bffa6790 100644 --- a/packages/svelte-query-persist-client/tests/PersistQueryClientProvider.svelte.test.ts +++ b/packages/svelte-query-persist-client/tests/PersistQueryClientProvider.svelte.test.ts @@ -8,7 +8,7 @@ import InitialData from './InitialData/Provider.svelte' import RemoveCache from './RemoveCache/Provider.svelte' import RestoreCache from './RestoreCache/Provider.svelte' import UseQueries from './UseQueries/Provider.svelte' -import { createQueryClient, queryKey, ref, sleep } from './utils.svelte' +import { createQueryClient, ref, sleep } from './utils.svelte' import type { PersistedClient, @@ -235,7 +235,7 @@ describe('PersistQueryClientProvider', () => { }, }) - await waitFor(() => rendered.getByText('data: null')) + await waitFor(() => rendered.getByText('data: undefined')) await waitFor(() => rendered.getByText('data: hydrated')) expect(fetched).toBe(false) diff --git a/packages/svelte-query-persist-client/tests/RemoveCache/Provider.svelte b/packages/svelte-query-persist-client/tests/RemoveCache/Provider.svelte index f71e987249..32e3430c4d 100644 --- a/packages/svelte-query-persist-client/tests/RemoveCache/Provider.svelte +++ b/packages/svelte-query-persist-client/tests/RemoveCache/Provider.svelte @@ -7,10 +7,9 @@ interface Props { queryClient: QueryClient persistOptions: OmitKeyof - key: Array } - let { queryClient, persistOptions, key }: Props = $props() + let { queryClient, persistOptions }: Props = $props() diff --git a/packages/svelte-query-persist-client/tests/RemoveCache/RemoveCache.svelte b/packages/svelte-query-persist-client/tests/RemoveCache/RemoveCache.svelte index 88f3a90eec..6aef3be046 100644 --- a/packages/svelte-query-persist-client/tests/RemoveCache/RemoveCache.svelte +++ b/packages/svelte-query-persist-client/tests/RemoveCache/RemoveCache.svelte @@ -11,5 +11,5 @@ }) -
{$query.data}
-
fetchStatus: {$query.fetchStatus}
+
{query.data}
+
fetchStatus: {query.fetchStatus}
diff --git a/packages/svelte-query-persist-client/tests/RestoreCache/Provider.svelte b/packages/svelte-query-persist-client/tests/RestoreCache/Provider.svelte index 6d7fd80942..c300d5010a 100644 --- a/packages/svelte-query-persist-client/tests/RestoreCache/Provider.svelte +++ b/packages/svelte-query-persist-client/tests/RestoreCache/Provider.svelte @@ -8,11 +8,10 @@ interface Props { queryClient: QueryClient persistOptions: OmitKeyof - key: Array states: { value: Array> } } - let { queryClient, persistOptions, key, states }: Props = $props() + let { queryClient, persistOptions, states }: Props = $props() diff --git a/packages/svelte-query-persist-client/tests/RestoreCache/RestoreCache.svelte b/packages/svelte-query-persist-client/tests/RestoreCache/RestoreCache.svelte index 008e71f4fc..82de410fcd 100644 --- a/packages/svelte-query-persist-client/tests/RestoreCache/RestoreCache.svelte +++ b/packages/svelte-query-persist-client/tests/RestoreCache/RestoreCache.svelte @@ -4,13 +4,7 @@ import { sleep } from '../utils.svelte' import type { StatusResult } from '../utils.svelte' - let { - key, - states, - }: { - key: Array - states: { value: Array> } - } = $props() + let { states }: { states: { value: Array> } } = $props() const query = createQuery({ queryKey: ['test'], @@ -25,5 +19,5 @@ }) -
{$query.data}
-
fetchStatus: {$query.fetchStatus}
+
{query.data}
+
fetchStatus: {query.fetchStatus}
diff --git a/packages/svelte-query-persist-client/tests/UseQueries/Provider.svelte b/packages/svelte-query-persist-client/tests/UseQueries/Provider.svelte index 3d3e954b9c..41a743b5f1 100644 --- a/packages/svelte-query-persist-client/tests/UseQueries/Provider.svelte +++ b/packages/svelte-query-persist-client/tests/UseQueries/Provider.svelte @@ -8,11 +8,10 @@ interface Props { queryClient: QueryClient persistOptions: OmitKeyof - key: Array states: { value: Array> } } - let { queryClient, persistOptions, key, states }: Props = $props() + let { queryClient, persistOptions, states }: Props = $props() diff --git a/packages/svelte-query-persist-client/tests/UseQueries/UseQueries.svelte b/packages/svelte-query-persist-client/tests/UseQueries/UseQueries.svelte index 70818781d4..89a9607c63 100644 --- a/packages/svelte-query-persist-client/tests/UseQueries/UseQueries.svelte +++ b/packages/svelte-query-persist-client/tests/UseQueries/UseQueries.svelte @@ -4,13 +4,7 @@ import { sleep } from '../utils.svelte' import type { StatusResult } from '../utils.svelte' - let { - key, - states, - }: { - key: Array - states: { value: Array> } - } = $props() + let { states }: { states: { value: Array> } } = $props() const queries = createQueries({ queries: [ @@ -25,9 +19,9 @@ }) $effect(() => { - states.value = [...untrack(() => states.value), $state.snapshot(s[0])] + states.value = [...untrack(() => states.value), $state.snapshot(queries[0])] }) -
{$queries[0].data}
-
fetchStatus: {$queries[0].fetchStatus}
+
{queries[0].data}
+
fetchStatus: {queries[0].fetchStatus}
diff --git a/packages/svelte-query/tests/createInfiniteQuery/BaseExample.svelte b/packages/svelte-query/tests/createInfiniteQuery/BaseExample.svelte index cd36ff55b7..3ff3924d4b 100644 --- a/packages/svelte-query/tests/createInfiniteQuery/BaseExample.svelte +++ b/packages/svelte-query/tests/createInfiniteQuery/BaseExample.svelte @@ -13,7 +13,7 @@ { queryKey: ['test'], queryFn: async ({ pageParam }) => { - await sleep(500) + await sleep(5) return Number(pageParam) }, getNextPageParam: (lastPage) => lastPage + 1,