in src/components/Database/testing/models.ts [19:44]
export function fakeReference({
key = null as string | null,
path = '',
data = null as any,
parent = null as firebase.database.Reference | null,
domain = 'http://localhost:9000',
} = {}): firebase.database.Reference {
return ({
key,
path,
parent,
child: jest.fn((path: string) => {
const paths = path.split('/');
const key = paths[paths.length - 1];
return fakeReference({ key, path: `${path}/${path}` });
}),
update: jest.fn(),
set: jest.fn(),
remove: jest.fn(),
once: jest.fn((event: string) => fakeSnapshot({ key, data })),
toString: jest.fn(() => `${domain}/${path}`),
database: {
app: { options: { databaseURL: 'http://localhost:9000/' } },
},
} as unknown) as firebase.database.Reference;
}