@@ -31,6 +31,27 @@ describe('微信小程序 web-view 桥接', () => {
|
||||
expect(document.querySelector('[data-wechat-js-sdk="true"]')).toBeNull()
|
||||
})
|
||||
|
||||
it('嵌入小程序时通过 navigateBack 返回宿主页', async () => {
|
||||
setEmbeddedRuntime()
|
||||
const { returnToWechatMiniProgram } = await loadService()
|
||||
const navigateBack = vi.fn(({ success }) => success())
|
||||
Object.assign(window, {
|
||||
wx: {
|
||||
miniProgram: {
|
||||
getEnv: (done: (value: { miniprogram: boolean }) => void) => done({ miniprogram: true }),
|
||||
navigateBack
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
await expect(returnToWechatMiniProgram()).resolves.toEqual({ status: 'returned' })
|
||||
expect(navigateBack).toHaveBeenCalledWith({
|
||||
delta: 1,
|
||||
success: expect.any(Function),
|
||||
fail: expect.any(Function)
|
||||
})
|
||||
})
|
||||
|
||||
it('等待延迟注入的 bridge 后导航到编码后的宿主页', async () => {
|
||||
setEmbeddedRuntime()
|
||||
const { openWechatMiniProgramLocation } = await loadService()
|
||||
|
||||
Reference in New Issue
Block a user