|
@@ -14,7 +14,7 @@ function fixture({ result, prepareFails } = {}) {
|
|
|
User: { current: () => ({ id: 'fixture-user' }) },
|
|
User: { current: () => ({ id: 'fixture-user' }) },
|
|
|
Cloud: { run: async (name, input) => {
|
|
Cloud: { run: async (name, input) => {
|
|
|
calls.push([name, input.orderId, input.loginCode]);
|
|
calls.push([name, input.orderId, input.loginCode]);
|
|
|
- if (prepareFails) throw { code: 209 };
|
|
|
|
|
|
|
+ if (prepareFails) throw { code: prepareFails === true ? 209 : prepareFails };
|
|
|
return { timeStamp: '1796000000', nonceStr: 'fixture', package: 'prepay_id=fixture', paySign: 'stub', signType: 'MD5' };
|
|
return { timeStamp: '1796000000', nonceStr: 'fixture', package: 'prepay_id=fixture', paySign: 'stub', signType: 'MD5' };
|
|
|
} },
|
|
} },
|
|
|
} };
|
|
} };
|
|
@@ -28,7 +28,7 @@ function fixture({ result, prepareFails } = {}) {
|
|
|
navigateBack: () => calls.push(['back']),
|
|
navigateBack: () => calls.push(['back']),
|
|
|
};
|
|
};
|
|
|
vm.runInNewContext(readFileSync('common-page/pages/native-payment/index.js', 'utf8'), {
|
|
vm.runInNewContext(readFileSync('common-page/pages/native-payment/index.js', 'utf8'), {
|
|
|
- Page: x => { definition = x; }, getApp: () => app, getCurrentPages: () => [opener, {}], wx,
|
|
|
|
|
|
|
+ Page: x => { definition = x; }, getApp: () => app, getCurrentPages: () => [opener, {}], wx, setTimeout, clearTimeout,
|
|
|
});
|
|
});
|
|
|
const page = { ...definition, data: { ...definition.data }, setData(patch) { Object.assign(this.data, patch); } };
|
|
const page = { ...definition, data: { ...definition.data }, setData(patch) { Object.assign(this.data, patch); } };
|
|
|
page.onLoad({ orderId: 'testOrder1', kind: 'recharge', fen: '9900' });
|
|
page.onLoad({ orderId: 'testOrder1', kind: 'recharge', fen: '9900' });
|
|
@@ -57,3 +57,11 @@ test('backend validation failure never invokes the native cashier', async () =>
|
|
|
assert.equal(calls.length, 1);
|
|
assert.equal(calls.length, 1);
|
|
|
assert.match(page.data.error, /身份.*不一致/);
|
|
assert.match(page.data.error, /身份.*不一致/);
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+test('a missing deployment shows a concrete error and resets loading', async () => {
|
|
|
|
|
+ const { page, calls } = fixture({ prepareFails: 141 });
|
|
|
|
|
+ await page.pay();
|
|
|
|
|
+ assert.equal(calls.length, 1);
|
|
|
|
|
+ assert.equal(page.data.paying, false);
|
|
|
|
|
+ assert.match(page.data.error, /支付服务暂未接通/);
|
|
|
|
|
+});
|