Skip to content

Commit 2e038b2

Browse files
committed
clean tests
1 parent f683e60 commit 2e038b2

File tree

4 files changed

+9
-28
lines changed

4 files changed

+9
-28
lines changed

src/map/utils/parsePB.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* @type {TileType[]}
44
*/
55
export const tileTypes = ['roadmap', 'satellite']
6+
const decoder = new TextDecoder()
67

78
/**
89
* Takes one bang operator and decodes it.
@@ -47,7 +48,7 @@ function convertType(item) {
4748
val = tileTypes[tileIndex < tileTypes.length && tileIndex >= 0 ? tileIndex : 0]
4849
break
4950
case 'z': // base64 encoded coords
50-
val = Uint8Array.fromBase64(item).toString('utf-8')
51+
val = decoder.decode(Uint8Array.fromBase64(item))
5152
}
5253

5354
return [val, type === 'm']

src/map/utils/read.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export async function readQ(addr) {
9292
const uri = encodeURI(nominatimQ + addr)
9393
const res = await fetch(uri)
9494

95-
if (!res.ok) {
95+
if (!res?.ok) {
9696
return null
9797
}
9898

src/test/read.test.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ globalThis.fetch = mock()
55

66
const input = 'test position'
77
const result = [{ lat: '1.1', lon: '1.1' }]
8+
const zoom = 32.648369576816776
9+
810

911
/**
1012
*
@@ -28,7 +30,7 @@ test('read pb: read example', async () => {
2830
},
2931
markers: [],
3032
tile: 'roadmap',
31-
zoom: 19,
33+
zoom,
3234
})
3335
})
3436

@@ -50,7 +52,7 @@ test('read pb: pb base64 marker', async () => {
5052
},
5153
],
5254
tile: 'roadmap',
53-
zoom: 19,
55+
zoom,
5456
})
5557
})
5658

@@ -66,7 +68,7 @@ test('read pb: pb id marker', async () => {
6668
},
6769
markers: [],
6870
tile: 'roadmap',
69-
zoom: 19,
71+
zoom,
7072
})
7173
})
7274

@@ -91,7 +93,7 @@ test('read pb: pb markers to readQ', async () => {
9193
},
9294
],
9395
tile: 'roadmap',
94-
zoom: 19,
96+
zoom,
9597
})
9698
})
9799

src/test/zoom.test.js

-22
This file was deleted.

0 commit comments

Comments
 (0)