fix wechat virtual payment coin flow
This commit is contained in:
@@ -11,6 +11,7 @@ const {
|
||||
|
||||
describe('wechat-pay mini program payment bridge', () => {
|
||||
beforeEach(() => {
|
||||
vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||
globalThis.wx = {
|
||||
requestPayment: vi.fn(),
|
||||
requestVirtualPayment: vi.fn(),
|
||||
@@ -100,8 +101,12 @@ describe('wechat-pay mini program payment bridge', () => {
|
||||
});
|
||||
|
||||
test('maps virtual payment cancel errCode to cancel result', async () => {
|
||||
const payError = {
|
||||
errCode: -2,
|
||||
errMsg: 'requestVirtualPayment:fail cancel',
|
||||
};
|
||||
globalThis.wx.requestVirtualPayment.mockImplementationOnce((options) => {
|
||||
options.fail?.({ errCode: -2, errMsg: 'requestVirtualPayment:fail cancel' });
|
||||
options.fail?.(payError);
|
||||
});
|
||||
|
||||
await expect(
|
||||
@@ -118,6 +123,10 @@ describe('wechat-pay mini program payment bridge', () => {
|
||||
errMsg: 'requestVirtualPayment:fail cancel',
|
||||
}),
|
||||
});
|
||||
expect(console.error).toHaveBeenCalledWith(
|
||||
'[wechat-pay] requestVirtualPayment failed',
|
||||
payError,
|
||||
);
|
||||
});
|
||||
|
||||
test('page notifies previous web-view after virtual payment', async () => {
|
||||
|
||||
Reference in New Issue
Block a user