Using full ISO dates as Gpx ids to support a wider range of dates.
This commit is contained in:
parent
441c623999
commit
12f0a8a10d
|
@ -57,6 +57,6 @@ describe('The gpx module', () => {
|
||||||
});
|
});
|
||||||
test('db.put() generates an id if needed', async () => {
|
test('db.put() generates an id if needed', async () => {
|
||||||
const id = await putNewGpx();
|
const id = await putNewGpx();
|
||||||
expect(id).toEqual({ gpx: '0' });
|
expect(id).toEqual({ gpx: '1970-01-01T00:00:00.000Z' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -31,7 +31,9 @@ const emptyGpx: Gpx = {
|
||||||
extensions: undefined,
|
extensions: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const putNewGpx = async (id: IdGpx = { gpx: Date.now().toString() }) => {
|
export const putNewGpx = async (
|
||||||
|
id: IdGpx = { gpx: new Date(Date.now()).toISOString() }
|
||||||
|
) => {
|
||||||
const uri = getUri('gpx', id);
|
const uri = getUri('gpx', id);
|
||||||
await put(
|
await put(
|
||||||
uri,
|
uri,
|
||||||
|
|
|
@ -26,23 +26,23 @@ describe('getFamily', () => {
|
||||||
});
|
});
|
||||||
test('returns two rows after a gpx and a track have been inserted.', async () => {
|
test('returns two rows after a gpx and a track have been inserted.', async () => {
|
||||||
await putNewTrk();
|
await putNewTrk();
|
||||||
const allDocs: any = await getFamily(uri('gpx', { gpx: '0' }));
|
const allDocs: any = await getFamily(uri('gpx', { gpx: '' }));
|
||||||
expect(allDocs).toMatchInlineSnapshot(`
|
expect(allDocs).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
"offset": 0,
|
"offset": 0,
|
||||||
"rows": Array [
|
"rows": Array [
|
||||||
Object {
|
Object {
|
||||||
"id": "gpx/0",
|
"id": "gpx/1970-01-01T00%3A00%3A00.000Z",
|
||||||
"key": "gpx/0",
|
"key": "gpx/1970-01-01T00%3A00%3A00.000Z",
|
||||||
"value": Object {
|
"value": Object {
|
||||||
"rev": "1-98d42c99fcf471a500b0506a60e77559",
|
"rev": "1-649694b1e46839ec63d2a93f483dd023",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"id": "gpx/0/2trk/00000",
|
"id": "gpx/1970-01-01T00%3A00%3A00.000Z/2trk/00000",
|
||||||
"key": "gpx/0/2trk/00000",
|
"key": "gpx/1970-01-01T00%3A00%3A00.000Z/2trk/00000",
|
||||||
"value": Object {
|
"value": Object {
|
||||||
"rev": "1-1e197ef8965a436730f80cabaaaa6f70",
|
"rev": "1-e1e6888ad978a5fcc405a75296604bee",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -52,7 +52,7 @@ Object {
|
||||||
});
|
});
|
||||||
test('also returns the docs if required.', async () => {
|
test('also returns the docs if required.', async () => {
|
||||||
await putNewTrk();
|
await putNewTrk();
|
||||||
const allDocs: any = await getFamily(uri('gpx', { gpx: '0' }), {
|
const allDocs: any = await getFamily(uri('gpx', { gpx: '' }), {
|
||||||
include_docs: true,
|
include_docs: true,
|
||||||
});
|
});
|
||||||
expect(allDocs).toMatchInlineSnapshot(`
|
expect(allDocs).toMatchInlineSnapshot(`
|
||||||
|
@ -61,8 +61,8 @@ Object {
|
||||||
"rows": Array [
|
"rows": Array [
|
||||||
Object {
|
Object {
|
||||||
"doc": Object {
|
"doc": Object {
|
||||||
"_id": "gpx/0",
|
"_id": "gpx/1970-01-01T00%3A00%3A00.000Z",
|
||||||
"_rev": "1-98d42c99fcf471a500b0506a60e77559",
|
"_rev": "1-649694b1e46839ec63d2a93f483dd023",
|
||||||
"doc": Object {
|
"doc": Object {
|
||||||
"$": Object {
|
"$": Object {
|
||||||
"creator": "dyomedea version 0.000002",
|
"creator": "dyomedea version 0.000002",
|
||||||
|
@ -81,25 +81,25 @@ Object {
|
||||||
},
|
},
|
||||||
"type": "gpx",
|
"type": "gpx",
|
||||||
},
|
},
|
||||||
"id": "gpx/0",
|
"id": "gpx/1970-01-01T00%3A00%3A00.000Z",
|
||||||
"key": "gpx/0",
|
"key": "gpx/1970-01-01T00%3A00%3A00.000Z",
|
||||||
"value": Object {
|
"value": Object {
|
||||||
"rev": "1-98d42c99fcf471a500b0506a60e77559",
|
"rev": "1-649694b1e46839ec63d2a93f483dd023",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"doc": Object {
|
"doc": Object {
|
||||||
"_id": "gpx/0/2trk/00000",
|
"_id": "gpx/1970-01-01T00%3A00%3A00.000Z/2trk/00000",
|
||||||
"_rev": "1-1e197ef8965a436730f80cabaaaa6f70",
|
"_rev": "1-e1e6888ad978a5fcc405a75296604bee",
|
||||||
"doc": Object {
|
"doc": Object {
|
||||||
"number": 0,
|
"number": 0,
|
||||||
},
|
},
|
||||||
"type": "trk",
|
"type": "trk",
|
||||||
},
|
},
|
||||||
"id": "gpx/0/2trk/00000",
|
"id": "gpx/1970-01-01T00%3A00%3A00.000Z/2trk/00000",
|
||||||
"key": "gpx/0/2trk/00000",
|
"key": "gpx/1970-01-01T00%3A00%3A00.000Z/2trk/00000",
|
||||||
"value": Object {
|
"value": Object {
|
||||||
"rev": "1-1e197ef8965a436730f80cabaaaa6f70",
|
"rev": "1-e1e6888ad978a5fcc405a75296604bee",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -109,30 +109,30 @@ Object {
|
||||||
});
|
});
|
||||||
test('returns three rows after a gpx and a track segment have been inserted.', async () => {
|
test('returns three rows after a gpx and a track segment have been inserted.', async () => {
|
||||||
await putNewTrkseg();
|
await putNewTrkseg();
|
||||||
const allDocs: any = await getFamily(uri('gpx', { gpx: '0' }));
|
const allDocs: any = await getFamily(uri('gpx', { gpx: '' }));
|
||||||
expect(allDocs).toMatchInlineSnapshot(`
|
expect(allDocs).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
"offset": 0,
|
"offset": 0,
|
||||||
"rows": Array [
|
"rows": Array [
|
||||||
Object {
|
Object {
|
||||||
"id": "gpx/0",
|
"id": "gpx/1970-01-01T00%3A00%3A00.000Z",
|
||||||
"key": "gpx/0",
|
"key": "gpx/1970-01-01T00%3A00%3A00.000Z",
|
||||||
"value": Object {
|
"value": Object {
|
||||||
"rev": "1-98d42c99fcf471a500b0506a60e77559",
|
"rev": "1-649694b1e46839ec63d2a93f483dd023",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"id": "gpx/0/2trk/00000",
|
"id": "gpx/1970-01-01T00%3A00%3A00.000Z/2trk/00000",
|
||||||
"key": "gpx/0/2trk/00000",
|
"key": "gpx/1970-01-01T00%3A00%3A00.000Z/2trk/00000",
|
||||||
"value": Object {
|
"value": Object {
|
||||||
"rev": "1-1e197ef8965a436730f80cabaaaa6f70",
|
"rev": "1-e1e6888ad978a5fcc405a75296604bee",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"id": "gpx/0/2trk/00000/00000",
|
"id": "gpx/1970-01-01T00%3A00%3A00.000Z/2trk/00000/00000",
|
||||||
"key": "gpx/0/2trk/00000/00000",
|
"key": "gpx/1970-01-01T00%3A00%3A00.000Z/2trk/00000/00000",
|
||||||
"value": Object {
|
"value": Object {
|
||||||
"rev": "1-33cb714b4d5553cc20fc7a753c63cf51",
|
"rev": "1-9d8fbcd9cb7d2a45d6caf57a2cbee7ca",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -142,37 +142,37 @@ Object {
|
||||||
});
|
});
|
||||||
test('returns four rows after a gpx and a track point have been inserted.', async () => {
|
test('returns four rows after a gpx and a track point have been inserted.', async () => {
|
||||||
await putNewTrkpt();
|
await putNewTrkpt();
|
||||||
const allDocs: any = await getFamily(uri('gpx', { gpx: '0' }));
|
const allDocs: any = await getFamily(uri('gpx', { gpx: '' }));
|
||||||
expect(allDocs).toMatchInlineSnapshot(`
|
expect(allDocs).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
"offset": 0,
|
"offset": 0,
|
||||||
"rows": Array [
|
"rows": Array [
|
||||||
Object {
|
Object {
|
||||||
"id": "gpx/0",
|
"id": "gpx/1970-01-01T00%3A00%3A00.000Z",
|
||||||
"key": "gpx/0",
|
"key": "gpx/1970-01-01T00%3A00%3A00.000Z",
|
||||||
"value": Object {
|
"value": Object {
|
||||||
"rev": "1-98d42c99fcf471a500b0506a60e77559",
|
"rev": "1-649694b1e46839ec63d2a93f483dd023",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"id": "gpx/0/2trk/00000",
|
"id": "gpx/1970-01-01T00%3A00%3A00.000Z/2trk/00000",
|
||||||
"key": "gpx/0/2trk/00000",
|
"key": "gpx/1970-01-01T00%3A00%3A00.000Z/2trk/00000",
|
||||||
"value": Object {
|
"value": Object {
|
||||||
"rev": "1-1e197ef8965a436730f80cabaaaa6f70",
|
"rev": "1-e1e6888ad978a5fcc405a75296604bee",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"id": "gpx/0/2trk/00000/00000",
|
"id": "gpx/1970-01-01T00%3A00%3A00.000Z/2trk/00000/00000",
|
||||||
"key": "gpx/0/2trk/00000/00000",
|
"key": "gpx/1970-01-01T00%3A00%3A00.000Z/2trk/00000/00000",
|
||||||
"value": Object {
|
"value": Object {
|
||||||
"rev": "1-33cb714b4d5553cc20fc7a753c63cf51",
|
"rev": "1-9d8fbcd9cb7d2a45d6caf57a2cbee7ca",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"id": "gpx/0/2trk/00000/00000/00000",
|
"id": "gpx/1970-01-01T00%3A00%3A00.000Z/2trk/00000/00000/00000",
|
||||||
"key": "gpx/0/2trk/00000/00000/00000",
|
"key": "gpx/1970-01-01T00%3A00%3A00.000Z/2trk/00000/00000/00000",
|
||||||
"value": Object {
|
"value": Object {
|
||||||
"rev": "1-c88eea2fc5a5637322a3f3357b49618f",
|
"rev": "1-42b858110cde8bec09e5d34b9e480936",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -183,23 +183,23 @@ Object {
|
||||||
|
|
||||||
test('returns two rows after a gpx and a waypoint have been inserted.', async () => {
|
test('returns two rows after a gpx and a waypoint have been inserted.', async () => {
|
||||||
await putNewWpt();
|
await putNewWpt();
|
||||||
const allDocs: any = await getFamily(uri('gpx', { gpx: '0' }));
|
const allDocs: any = await getFamily(uri('gpx', { gpx: '' }));
|
||||||
expect(allDocs).toMatchInlineSnapshot(`
|
expect(allDocs).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
"offset": 0,
|
"offset": 0,
|
||||||
"rows": Array [
|
"rows": Array [
|
||||||
Object {
|
Object {
|
||||||
"id": "gpx/0",
|
"id": "gpx/1970-01-01T00%3A00%3A00.000Z",
|
||||||
"key": "gpx/0",
|
"key": "gpx/1970-01-01T00%3A00%3A00.000Z",
|
||||||
"value": Object {
|
"value": Object {
|
||||||
"rev": "1-98d42c99fcf471a500b0506a60e77559",
|
"rev": "1-649694b1e46839ec63d2a93f483dd023",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"id": "gpx/0/0wpt/00000",
|
"id": "gpx/1970-01-01T00%3A00%3A00.000Z/0wpt/00000",
|
||||||
"key": "gpx/0/0wpt/00000",
|
"key": "gpx/1970-01-01T00%3A00%3A00.000Z/0wpt/00000",
|
||||||
"value": Object {
|
"value": Object {
|
||||||
"rev": "1-dcdc55abd413b401dba4278510d9c51b",
|
"rev": "1-f98b9048879fc7b97771bf2bafc77e42",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -210,23 +210,23 @@ Object {
|
||||||
|
|
||||||
test('returns two rows after a gpx and a route have been inserted.', async () => {
|
test('returns two rows after a gpx and a route have been inserted.', async () => {
|
||||||
await putNewRte();
|
await putNewRte();
|
||||||
const allDocs: any = await getFamily(uri('gpx', { gpx: '0' }));
|
const allDocs: any = await getFamily(uri('gpx', { gpx: '' }));
|
||||||
expect(allDocs).toMatchInlineSnapshot(`
|
expect(allDocs).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
"offset": 0,
|
"offset": 0,
|
||||||
"rows": Array [
|
"rows": Array [
|
||||||
Object {
|
Object {
|
||||||
"id": "gpx/0",
|
"id": "gpx/1970-01-01T00%3A00%3A00.000Z",
|
||||||
"key": "gpx/0",
|
"key": "gpx/1970-01-01T00%3A00%3A00.000Z",
|
||||||
"value": Object {
|
"value": Object {
|
||||||
"rev": "1-98d42c99fcf471a500b0506a60e77559",
|
"rev": "1-649694b1e46839ec63d2a93f483dd023",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"id": "gpx/0/1rte/00000",
|
"id": "gpx/1970-01-01T00%3A00%3A00.000Z/1rte/00000",
|
||||||
"key": "gpx/0/1rte/00000",
|
"key": "gpx/1970-01-01T00%3A00%3A00.000Z/1rte/00000",
|
||||||
"value": Object {
|
"value": Object {
|
||||||
"rev": "1-bce69fd9ada837c19cf8c1c296f82f92",
|
"rev": "1-f17cd2939d1e63764478613f54835884",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -237,30 +237,30 @@ Object {
|
||||||
|
|
||||||
test('returns three rows after a gpx and a route point have been inserted.', async () => {
|
test('returns three rows after a gpx and a route point have been inserted.', async () => {
|
||||||
await putNewRtept();
|
await putNewRtept();
|
||||||
const allDocs: any = await getFamily(uri('gpx', { gpx: '0' }));
|
const allDocs: any = await getFamily(uri('gpx', { gpx: '' }));
|
||||||
expect(allDocs).toMatchInlineSnapshot(`
|
expect(allDocs).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
"offset": 0,
|
"offset": 0,
|
||||||
"rows": Array [
|
"rows": Array [
|
||||||
Object {
|
Object {
|
||||||
"id": "gpx/0",
|
"id": "gpx/1970-01-01T00%3A00%3A00.000Z",
|
||||||
"key": "gpx/0",
|
"key": "gpx/1970-01-01T00%3A00%3A00.000Z",
|
||||||
"value": Object {
|
"value": Object {
|
||||||
"rev": "1-98d42c99fcf471a500b0506a60e77559",
|
"rev": "1-649694b1e46839ec63d2a93f483dd023",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"id": "gpx/0/1rte/00000",
|
"id": "gpx/1970-01-01T00%3A00%3A00.000Z/1rte/00000",
|
||||||
"key": "gpx/0/1rte/00000",
|
"key": "gpx/1970-01-01T00%3A00%3A00.000Z/1rte/00000",
|
||||||
"value": Object {
|
"value": Object {
|
||||||
"rev": "1-bce69fd9ada837c19cf8c1c296f82f92",
|
"rev": "1-f17cd2939d1e63764478613f54835884",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"id": "gpx/0/1rte/00000/00000",
|
"id": "gpx/1970-01-01T00%3A00%3A00.000Z/1rte/00000/00000",
|
||||||
"key": "gpx/0/1rte/00000/00000",
|
"key": "gpx/1970-01-01T00%3A00%3A00.000Z/1rte/00000/00000",
|
||||||
"value": Object {
|
"value": Object {
|
||||||
"rev": "1-1045e2dc6d2f7927514b02f79d14daa8",
|
"rev": "1-ba3f25be70b620dd06b453ec29853bae",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -43,6 +43,6 @@ describe('The rte module', () => {
|
||||||
});
|
});
|
||||||
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
||||||
const id = await putNewRte();
|
const id = await putNewRte();
|
||||||
expect(id).toEqual({ gpx: '0', rte: '00000' });
|
expect(id).toEqual({ gpx: '1970-01-01T00:00:00.000Z', rte: '00000' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -53,6 +53,6 @@ describe('The rtept module', () => {
|
||||||
});
|
});
|
||||||
test('db.put() generates ids for both gpx and rte if needed', async () => {
|
test('db.put() generates ids for both gpx and rte if needed', async () => {
|
||||||
const id = await putNewRtept();
|
const id = await putNewRtept();
|
||||||
expect(id).toEqual({ gpx: '0', rte: '00000', rtept: '00000' });
|
expect(id).toEqual({ gpx: '1970-01-01T00:00:00.000Z', rte: '00000', rtept: '00000' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -42,6 +42,6 @@ describe('The trk module', () => {
|
||||||
});
|
});
|
||||||
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
||||||
const id = await putNewTrk();
|
const id = await putNewTrk();
|
||||||
expect(id).toEqual({ gpx: '0', trk: '00000' });
|
expect(id).toEqual({ gpx: '1970-01-01T00:00:00.000Z', trk: '00000' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -70,7 +70,7 @@ describe('The trkpt module', () => {
|
||||||
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
||||||
const id = await putNewTrkpt();
|
const id = await putNewTrkpt();
|
||||||
expect(id).toEqual({
|
expect(id).toEqual({
|
||||||
gpx: '0',
|
gpx: '1970-01-01T00:00:00.000Z',
|
||||||
trk: '00000',
|
trk: '00000',
|
||||||
trkseg: '00000',
|
trkseg: '00000',
|
||||||
trkpt: '00000',
|
trkpt: '00000',
|
||||||
|
|
|
@ -35,6 +35,6 @@ describe('The trkseg module', () => {
|
||||||
});
|
});
|
||||||
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
||||||
const id = await putNewTrkseg();
|
const id = await putNewTrkseg();
|
||||||
expect(id).toEqual({ gpx: '0', trk: '00000', trkseg: '00000' });
|
expect(id).toEqual({ gpx: '1970-01-01T00:00:00.000Z', trk: '00000', trkseg: '00000' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -53,6 +53,6 @@ describe('The wpt module', () => {
|
||||||
});
|
});
|
||||||
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
||||||
const id = await putNewWpt();
|
const id = await putNewWpt();
|
||||||
expect(id).toEqual({ gpx: '0', wpt: '00000' });
|
expect(id).toEqual({ gpx: '1970-01-01T00:00:00.000Z', wpt: '00000' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue