Add AMap location and weather header with warm mini program theme
This commit is contained in:
@@ -97,3 +97,40 @@ test("约遛详情识别已报名并能退出", async () => {
|
||||
await screen.leave();
|
||||
assert.deepEqual(calls[1], { route: "/meetups/event-1/join", method: "DELETE" });
|
||||
});
|
||||
|
||||
test("首页使用 GCJ-02 定位并展示真实城市天气", async () => {
|
||||
const screen = page("home", async (route, method, body) => {
|
||||
assert.equal(route, "/environment");
|
||||
assert.equal(method, "GET");
|
||||
assert.deepEqual(body, { latitude: 30.2, longitude: 120.1 });
|
||||
return { location_name: "杭州市 · 西湖区", weather: { description: "小雨", temperature: "19" } };
|
||||
}, {
|
||||
getSetting: ({ success }) => success({ authSetting: { "scope.userLocation": true } }),
|
||||
getLocation: ({ type, success }) => {
|
||||
assert.equal(type, "gcj02");
|
||||
success({ latitude: 30.2, longitude: 120.1 });
|
||||
},
|
||||
});
|
||||
await screen.refreshEnvironment();
|
||||
assert.equal(screen.data.locationName, "杭州市 · 西湖区");
|
||||
assert.match(screen.data.headerSubtitle, /周. · 小雨 19°C$/);
|
||||
});
|
||||
|
||||
test("拒绝定位不请求后端,点击后可以恢复授权", async () => {
|
||||
let calls = 0;
|
||||
const screen = page("home", async () => {
|
||||
calls++;
|
||||
return { location_name: "杭州市", weather: null };
|
||||
}, {
|
||||
getSetting: ({ success }) => success({ authSetting: { "scope.userLocation": false } }),
|
||||
openSetting: ({ success }) => success({ authSetting: { "scope.userLocation": true } }),
|
||||
getLocation: ({ success }) => success({ latitude: 30.2, longitude: 120.1 }),
|
||||
});
|
||||
await screen.refreshEnvironment();
|
||||
assert.equal(calls, 0);
|
||||
assert.equal(screen.data.locationName, "开启定位");
|
||||
await screen.refreshEnvironment({ type: "locationtap" });
|
||||
assert.equal(calls, 1);
|
||||
assert.equal(screen.data.locationName, "杭州市");
|
||||
assert.match(screen.data.headerSubtitle, /天气暂不可用$/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user