mirror of
https://github.com/directus/directus.git
synced 2026-02-18 22:44:34 -05:00
@@ -11,6 +11,7 @@ import { useCollection } from './use-collection.js';
|
||||
const mockData = { id: 1 };
|
||||
const mockCountData = { count: 2 };
|
||||
const mockCountDistinctData = { countDistinct: { id: 3 } };
|
||||
|
||||
const mockPrimaryKeyField: Field = {
|
||||
collection: 'test_collection',
|
||||
field: 'id',
|
||||
@@ -19,6 +20,7 @@ const mockPrimaryKeyField: Field = {
|
||||
schema: null,
|
||||
meta: null,
|
||||
};
|
||||
|
||||
const mockApiGet = vi.fn();
|
||||
const mockApiPost = vi.fn();
|
||||
|
||||
@@ -50,6 +52,7 @@ vi.mock('./use-system.js', () => ({
|
||||
post: mockApiPost,
|
||||
})),
|
||||
}));
|
||||
|
||||
vi.mock('./use-collection.js');
|
||||
|
||||
afterEach(() => {
|
||||
|
||||
@@ -63,6 +63,7 @@ export function useItems(collection: Ref<string | null>, query: ComputedQuery):
|
||||
total: null,
|
||||
filter: null,
|
||||
};
|
||||
|
||||
let loadingTimeout: NodeJS.Timeout | null = null;
|
||||
|
||||
const fetchItems = throttle(getItems, 500);
|
||||
@@ -250,6 +251,7 @@ export function useItems(collection: Ref<string | null>, query: ComputedQuery):
|
||||
const count = primaryKeyField.value
|
||||
? Number(response.data.data[0].countDistinct[primaryKeyField.value.field])
|
||||
: Number(response.data.data[0].count);
|
||||
|
||||
existingRequests.total = null;
|
||||
|
||||
totalCount.value = count;
|
||||
@@ -287,6 +289,7 @@ export function useItems(collection: Ref<string | null>, query: ComputedQuery):
|
||||
const count = primaryKeyField.value
|
||||
? Number(response.data.data[0].countDistinct[primaryKeyField.value.field])
|
||||
: Number(response.data.data[0].count);
|
||||
|
||||
existingRequests.filter = null;
|
||||
|
||||
itemCount.value = count;
|
||||
|
||||
Reference in New Issue
Block a user