import { DocumentReference, DocumentData, Firestore, CollectionReference } from '@google-cloud/firestore';

// Define a mocked transaction interface
export interface MockedTransaction {
    set: jest.Mock;
    get: jest.Mock;
}

// Define a mocked collection reference interface
export interface MockedCollectionReference {
    doc: jest.Mock<jest.Mocked<DocumentReference<DocumentData>>, [string]>;
    where: jest.Mock;
    get: jest.Mock;
}

// Define a mocked Firestore interface
export interface MockedFirestore {
    collection: jest.Mock<MockedCollectionReference, [string]>;
    runTransaction: jest.Mock<
        Promise<any>,
        [
            (
                transaction: MockedTransaction
            ) => Promise<any>
        ]
    >;
    FieldValue: {
        serverTimestamp: jest.Mock<Date, []>;
    };
    doc: jest.Mock<jest.Mocked<DocumentReference<DocumentData>>, [string]>;
}

// Mock implementations for query methods
const whereFunction = jest.fn().mockReturnThis();
const getFunction = jest.fn().mockResolvedValue({ empty: true });

// Define a mocked DocumentReference
const docMock: jest.Mocked<DocumentReference<DocumentData>> = {
    id: 'test-game-id',
    firestore: {} as jest.Mocked<Firestore>,
    parent: {} as jest.Mocked<CollectionReference<DocumentData>>,
    path: 'games/test-game-id',
    collection: jest.fn(),
    set: jest.fn(),
    update: jest.fn(),
    delete: jest.fn(),
    get: jest.fn(),
    onSnapshot: jest.fn(),
    withConverter: jest.fn(),
};

// Mock Firestore collection
const collection = jest.fn<MockedCollectionReference, [string]>(() => ({
    doc: jest.fn().mockReturnValue(docMock),
    where: whereFunction,
    get: getFunction,
}));

// Mock runTransaction
const runTransaction = jest.fn().mockImplementation(async (
    updateFunction: (transaction: MockedTransaction) => Promise<any>
) => {
    const transaction: MockedTransaction = {
        set: jest.fn(),
        get: jest.fn().mockResolvedValue({ data: () => ({}) }),
    };
    return updateFunction(transaction);
});

// Mock FieldValue.serverTimestamp
const serverTimestamp = jest.fn(() => new Date());

// Mock Firestore instance
const firestore: MockedFirestore = {
    collection,
    runTransaction,
    FieldValue: {
        serverTimestamp,
    },
    doc: jest.fn().mockReturnValue(docMock),
};

// Mock admin SDK
const admin = {
    apps: [],
    initializeApp: jest.fn(),
    firestore: jest.fn(() => firestore),
};

export default admin;

----

error TS2322: Type '{ id: string; firestore: jest.Mocked<Firestore>; parent: jest.Mocked<CollectionReference<DocumentData, DocumentData>>; ... 7 more ...; withConverter: jest.Mock<...>; }' is not assignable to type 'Mocked<DocumentReference<DocumentData, DocumentData>>'.
      Type '{ id: string; firestore: Mocked<Firestore>; parent: Mocked<CollectionReference<DocumentData, DocumentData>>; ... 7 more ...; withConverter: Mock<...>; }' is missing the following properties from type '{ readonly id: string; readonly firestore: Firestore; readonly parent: CollectionReference<DocumentData, DocumentData>; ... 10 more ...; withConverter: MockInstance<...>; }': listCollections, create, isEqual

    38 const docMock: jest.Mocked<DocumentReference<DocumentData>> = {

---

fix the error