Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -612,10 +612,7 @@ describe('injectQuery', () => {
const query = TestBed.runInInjectionContext(() =>
injectQuery(() => ({
queryKey: ['pendingTasksTest'],
queryFn: async () => {
await sleep(50)
return 'test data'
},
queryFn: () => sleep(50).then(() => 'test data'),
})),
)

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -283,17 +283,12 @@ describe('PendingTasks Integration', () => {
class TestComponent {
query = injectQuery(() => ({
queryKey: ['component-query'],
queryFn: async () => {
await sleep(100)
return 'component-data'
},
queryFn: () => sleep(100).then(() => 'component-data'),
}))

mutation = injectMutation(() => ({
mutationFn: async (data: string) => {
await sleep(100)
return `processed: ${data}`
},
mutationFn: (data: string) =>
sleep(100).then(() => `processed: ${data}`),
}))
}

Expand DownExpand Up@@ -338,20 +333,14 @@ describe('PendingTasks Integration', () => {
const query1 = TestBed.runInInjectionContext(() =>
injectQuery(() => ({
queryKey: ['concurrent-1'],
queryFn: async () => {
await sleep(30)
return 'data-1'
},
queryFn: () => sleep(30).then(() => 'data-1'),
})),
)

const query2 = TestBed.runInInjectionContext(() =>
injectQuery(() => ({
queryKey: ['concurrent-2'],
queryFn: async () => {
await sleep(50)
return 'data-2'
},
queryFn: () => sleep(50).then(() => 'data-2'),
})),
)

Expand DownExpand Up@@ -385,19 +374,15 @@ describe('PendingTasks Integration', () => {

const mutation1 = TestBed.runInInjectionContext(() =>
injectMutation(() => ({
mutationFn: async (data: string) => {
await sleep(30)
return `processed-1: ${data}`
},
mutationFn: (data: string) =>
sleep(30).then(() => `processed-1: ${data}`),
})),
)

const mutation2 = TestBed.runInInjectionContext(() =>
injectMutation(() => ({
mutationFn: async (data: string) => {
await sleep(50)
return `processed-2: ${data}`
},
mutationFn: (data: string) =>
sleep(50).then(() => `processed-2: ${data}`),
})),
)

Expand DownExpand Up@@ -436,19 +421,14 @@ describe('PendingTasks Integration', () => {
const query = TestBed.runInInjectionContext(() =>
injectQuery(() => ({
queryKey: ['mixed-query'],
queryFn: async () => {
await sleep(40)
return 'query-data'
},
queryFn: () => sleep(40).then(() => 'query-data'),
})),
)

const mutation = TestBed.runInInjectionContext(() =>
injectMutation(() => ({
mutationFn: async (data: string) => {
await sleep(60)
return `mutation: ${data}`
},
mutationFn: (data: string) =>
sleep(60).then(() => `mutation: ${data}`),
})),
)

Expand DownExpand Up@@ -561,10 +541,7 @@ describe('PendingTasks Integration', () => {
const query = TestBed.runInInjectionContext(() =>
injectQuery(() => ({
queryKey: ['cancel-test'],
queryFn: async () => {
await sleep(100)
return 'data'
},
queryFn: () => sleep(100).then(() => 'data'),
})),
)

Expand DownExpand Up@@ -623,10 +600,7 @@ describe('PendingTasks Integration', () => {

const mutation = TestBed.runInInjectionContext(() =>
injectMutation(() => ({
mutationFn: async (newData: string) => {
await sleep(50)
return newData
},
mutationFn: (newData: string) => sleep(50).then(() => newData),
onMutate: async (newData) => {
// Optimistic update
const previousData = queryClient.getQueryData(testQueryKey)
Expand Down
Loading