48 lines
1.0 KiB
TypeScript
48 lines
1.0 KiB
TypeScript
|
import { initDb } from '.';
|
||
|
import uri from '../lib/ids';
|
||
|
import { getFamily } from './lib';
|
||
|
import { putNewTrk } from './trk';
|
||
|
|
||
|
declare global {
|
||
|
var db: any;
|
||
|
}
|
||
|
|
||
|
const originalDateNow = globalThis.Date.now;
|
||
|
|
||
|
describe('getFamily', () => {
|
||
|
beforeEach(async () => {
|
||
|
await initDb({});
|
||
|
globalThis.Date.now = () => 0;
|
||
|
});
|
||
|
afterEach(async () => {
|
||
|
await db.destroy();
|
||
|
globalThis.Date.now = originalDateNow;
|
||
|
});
|
||
|
test('returns two rows after a gpx and a track have been inserted.', async () => {
|
||
|
await putNewTrk();
|
||
|
const allDocs: any = await getFamily(uri('gpx', { gpx: '0' }));
|
||
|
expect(allDocs).toMatchInlineSnapshot(`
|
||
|
Object {
|
||
|
"offset": 0,
|
||
|
"rows": Array [
|
||
|
Object {
|
||
|
"id": "gpx/0",
|
||
|
"key": "gpx/0",
|
||
|
"value": Object {
|
||
|
"rev": "1-98d42c99fcf471a500b0506a60e77559",
|
||
|
},
|
||
|
},
|
||
|
Object {
|
||
|
"id": "gpx/0/2trk/00000",
|
||
|
"key": "gpx/0/2trk/00000",
|
||
|
"value": Object {
|
||
|
"rev": "1-1e197ef8965a436730f80cabaaaa6f70",
|
||
|
},
|
||
|
},
|
||
|
],
|
||
|
"total_rows": 5,
|
||
|
}
|
||
|
`);
|
||
|
});
|
||
|
});
|