vending-machine/mobile/__tests__/payment.property.test.js
2026-04-08 20:45:41 +08:00

32 lines
1017 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { describe, it, expect } from 'vitest'
import * as fc from 'fast-check'
import { resolvePaymentChannel } from '../utils/payment.js'
describe('Property 16: 支付渠道平台选择', () => {
/**
* **Feature: mobile-app, Property 16: 支付渠道平台选择**
* **Validates: Requirements 12.2, 12.3**
*
* 对于任意支付请求当平台为Android时应调用Google Pay接口
* 当平台为iOS时应调用Apple Pay接口。
*/
it('Android平台应选择Google PayiOS平台应选择Apple Pay', () => {
const platformArb = fc.constantFrom('android', 'ios', 'unknown')
fc.assert(
fc.property(platformArb, (platform) => {
const channel = resolvePaymentChannel(platform)
if (platform === 'android') {
expect(channel).toBe('google_pay')
} else if (platform === 'ios') {
expect(channel).toBe('apple_pay')
} else {
expect(channel).toBe('unsupported')
}
}),
{ numRuns: 100 }
)
})
})