改用高德地图附近 POI 查询发货地,移除闲鱼定位接口调用。发货地改为可选项,虚拟商品可直接发布;修正闲鱼网页版要求的纬度、经度 GPS 顺序,并补充前端映射与发布测试。
36 lines
915 B
TypeScript
36 lines
915 B
TypeScript
import { expect, test } from 'vitest';
|
|
import { amapPOIToPublishLocation } from './amapLocation';
|
|
|
|
test('maps AMap POI fields to the publish location shape', () => {
|
|
expect(amapPOIToPublishLocation({
|
|
id: 'B000A74398',
|
|
name: '人民广场',
|
|
address: '人民大道',
|
|
adname: '黄浦区',
|
|
cityname: '上海市',
|
|
adcode: '310101',
|
|
pname: '上海市',
|
|
location: { lng: 121.4737, lat: 31.2304 },
|
|
})).toEqual({
|
|
area: '黄浦区',
|
|
city: '上海市',
|
|
division_id: '310101',
|
|
longitude: 121.4737,
|
|
latitude: 31.2304,
|
|
poi_id: 'B000A74398',
|
|
poi_name: '人民广场',
|
|
province: '上海市',
|
|
});
|
|
});
|
|
|
|
test('drops incomplete or invalid AMap POIs', () => {
|
|
expect(amapPOIToPublishLocation({
|
|
id: 'poi',
|
|
name: '无坐标',
|
|
adcode: '310101',
|
|
pname: '上海市',
|
|
cityname: '上海市',
|
|
location: { lng: 0, lat: 31.2 },
|
|
})).toBeNull();
|
|
});
|