@jetthai/cuora 1.2.0 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BREAKING_CHANGES.md +9 -0
- package/CHANGELOG.md +36 -0
- package/package.json +5 -2
- package/resetGitBranch.sh +16 -16
- package/src/api/account.js +8 -0
- package/src/api/auth.js +1 -1
- package/src/api/common.js +6 -1
- package/src/api/index.js +3 -1
- package/src/api/otp.js +5 -0
- package/src/api/user.js +1 -0
- package/src/machine/activity/activity.js +23 -19
- package/src/machine/activity/activity_cash.js +27 -22
- package/src/machine/activity/cash_rain_activity.js +1 -0
- package/src/machine/activity/continue_deposit_activity.js +1 -0
- package/src/machine/activity/deposit_activity.js +1 -0
- package/src/machine/activity/diamond_shop_activity_cash.js +7 -0
- package/src/machine/activity/diamond_shop_activity_fc.js +1 -0
- package/src/machine/activity/diamond_shop_activity_vn.js +1 -0
- package/src/machine/activity/fafafa_activity.js +1 -0
- package/src/machine/activity/friend_invite_friends_activity.js +7 -8
- package/src/machine/activity/instant_rebate_activity.js +1 -0
- package/src/machine/activity/invite_friends_activity.js +1 -0
- package/src/machine/activity/jackpot.js +1 -0
- package/src/machine/activity/mini_game_activity.js +1 -0
- package/src/machine/activity/otp_verified_activity.js +1 -0
- package/src/machine/activity/ranking_activity.js +1 -0
- package/src/machine/activity/return_bonus_activity.js +3 -1
- package/src/machine/activity/roulette_activity_v2.js +6 -0
- package/src/machine/activity/sign_in_activity.js +1 -0
- package/src/machine/activity/sign_in_monthly_activity.js +2 -1
- package/src/machine/activity/specify_bets_activity.js +1 -0
- package/src/machine/activity/specify_turnover_activity.js +1 -0
- package/src/machine/activity/time_bomb_activity.js +1 -0
- package/src/machine/activity/vip_card_activity.js +1 -0
- package/src/machine/auth.js +18 -6
- package/src/machine/auth_otp_v2.js +1 -0
- package/src/machine/auth_otp_v3.js +48 -11
- package/src/machine/bank_binding.js +1 -0
- package/src/machine/bank_binding_amb.js +1 -0
- package/src/machine/bonus.js +1 -0
- package/src/machine/common.js +24 -4
- package/src/machine/deposit/amb.js +1 -0
- package/src/machine/deposit/crypto_bank.js +20 -5
- package/src/machine/deposit/crypto_bank_cash.js +35 -9
- package/src/machine/deposit/crypto_qrcode.js +11 -1
- package/src/machine/deposit/crypto_qrcode_cash.js +24 -1
- package/src/machine/deposit/crypto_way.js +11 -5
- package/src/machine/deposit/crypto_way_cash.js +15 -6
- package/src/machine/deposit/deposit_fc.js +1 -0
- package/src/machine/deposit/direct.js +1 -0
- package/src/machine/deposit/direct_cash.js +1 -0
- package/src/machine/deposit/float.js +1 -0
- package/src/machine/deposit/krway.js +1 -0
- package/src/machine/deposit/loadcard_cash.js +2 -1
- package/src/machine/deposit/loadcard_vn.js +1 -0
- package/src/machine/deposit/manual_cash.js +1 -0
- package/src/machine/deposit/manual_vn.js +1 -0
- package/src/machine/deposit/qrcode_cash.js +6 -5
- package/src/machine/deposit/qrcode_v2.js +1 -0
- package/src/machine/deposit/usdt.js +23 -4
- package/src/machine/deposit/usdt_cash.js +15 -1
- package/src/machine/deposit/virtual_bank_cash.js +11 -9
- package/src/machine/deposit/virtual_bank_vn.js +1 -0
- package/src/machine/deposit/vpay.js +7 -0
- package/src/machine/error.js +1 -0
- package/src/machine/game_betslip.js +1 -0
- package/src/machine/game_favorite_v2.js +1 -0
- package/src/machine/game_hot_new.js +1 -0
- package/src/machine/game_info.js +5 -0
- package/src/machine/game_replay.js +1 -0
- package/src/machine/game_search_cash.js +1 -0
- package/src/machine/game_search_v2.js +1 -0
- package/src/machine/game_v2_1.js +88 -46
- package/src/machine/honor_board.js +1 -0
- package/src/machine/honor_board_cash.js +11 -8
- package/src/machine/inbox.js +93 -43
- package/src/machine/leaderboard.js +1 -0
- package/src/machine/merge.js +1 -0
- package/src/machine/navbar.js +3 -1
- package/src/machine/payment_data.js +1 -0
- package/src/machine/promotions.js +11 -18
- package/src/machine/ranking.js +5 -2
- package/src/machine/reward.js +1 -0
- package/src/machine/reward_cash.js +1 -0
- package/src/machine/reward_fc.js +1 -0
- package/src/machine/roulette_v2.js +18 -26
- package/src/machine/setting.js +1 -0
- package/src/machine/side.js +10 -4
- package/src/machine/side_cash.js +1 -0
- package/src/machine/side_v2.js +38 -24
- package/src/machine/user_info.js +1 -0
- package/src/machine/user_photo.js +1 -0
- package/src/machine/user_reset_password.js +5 -2
- package/src/machine/user_sign_up.js +1 -0
- package/src/machine/vip_table.js +1 -0
- package/src/machine/websocket.js +42 -14
- package/src/machine/welcome.js +1 -0
- package/src/machine/withdraw/withdraw_crypto_cash.js +1 -0
- package/src/machine/withdraw/withdraw_krway.js +1 -0
- package/src/machine/withdraw/withdraw_manual.js +16 -8
- package/src/machine/withdraw/withdraw_manual_cash.js +1 -0
- package/src/request/request.js +34 -30
- package/src/util/deviceToken.js +7 -6
- package/src/util/storage.js +4 -3
- package/test/api.behavior.test.js +69 -0
- package/test/api.contract.test.js +18 -0
- package/test/config.test.js +27 -0
- package/test/deviceToken.test.js +139 -0
- package/test/helpers.coverage.test.js +11 -0
- package/test/helpers.js +91 -0
- package/test/index.exports.test.js +14 -0
- package/test/machine.activity.core.coverage.test.js +337 -0
- package/test/machine.activity.gap.coverage.test.js +252 -0
- package/test/machine.activity.more.coverage.test.js +180 -0
- package/test/machine.activity_plus_and_binding_amb.coverage.test.js +201 -0
- package/test/machine.activity_timer_bonus.coverage.test.js +136 -0
- package/test/machine.activity_welcome.low.coverage.test.js +211 -0
- package/test/machine.amb_rewardfc_websocket.more.coverage.test.js +201 -0
- package/test/machine.auth.coverage.test.js +215 -0
- package/test/machine.bank_binding.test.js +143 -0
- package/test/machine.binding_otp_krway.coverage.test.js +223 -0
- package/test/machine.contract.test.js +50 -0
- package/test/machine.crypto_bank.coverage.test.js +270 -0
- package/test/machine.crypto_way.coverage.test.js +108 -0
- package/test/machine.crypto_way_cash.coverage.test.js +114 -0
- package/test/machine.definition.test.js +137 -0
- package/test/machine.deposit.manual.coverage.test.js +365 -0
- package/test/machine.deposit_fc.coverage.test.js +126 -0
- package/test/machine.direct.coverage.test.js +96 -0
- package/test/machine.direct_cash.coverage.test.js +108 -0
- package/test/machine.error.coverage.test.js +37 -0
- package/test/machine.events.test.js +126 -0
- package/test/machine.favorite_jackpot.coverage.test.js +82 -0
- package/test/machine.float.coverage.test.js +136 -0
- package/test/machine.flow.test.js +226 -0
- package/test/machine.game_hot_new_vip_table.coverage.test.js +105 -0
- package/test/machine.game_search_cash.coverage.test.js +155 -0
- package/test/machine.game_search_v2.test.js +199 -0
- package/test/machine.game_user_profile.coverage.test.js +100 -0
- package/test/machine.honor_board.test.js +133 -0
- package/test/machine.inbox.common.coverage.test.js +304 -0
- package/test/machine.loadcard_cash.coverage.test.js +101 -0
- package/test/machine.loadcard_vn.coverage.test.js +122 -0
- package/test/machine.misc.coverage.test.js +361 -0
- package/test/machine.more2.coverage.test.js +261 -0
- package/test/machine.options.execution.test.js +272 -0
- package/test/machine.priority.coverage.test.js +603 -0
- package/test/machine.qrcode_cash.coverage.test.js +107 -0
- package/test/machine.qrcode_v2.coverage.test.js +121 -0
- package/test/machine.regression.test.js +82 -0
- package/test/machine.roulette_v2.test.js +142 -0
- package/test/machine.side_reward_reset.coverage.test.js +220 -0
- package/test/machine.targeted.coverage.test.js +313 -0
- package/test/machine.usdt.coverage.test.js +95 -0
- package/test/machine.usdt_cash.coverage.test.js +73 -0
- package/test/machine.vip_card_activity.test.js +114 -0
- package/test/machine.virtual_bank_cash.coverage.test.js +105 -0
- package/test/machine.virtual_bank_vn.coverage.test.js +105 -0
- package/test/machine.vpay.coverage.test.js +142 -0
- package/test/machine.withdraw_crypto_cash.coverage.test.js +166 -0
- package/test/machine.withdraw_krway.coverage.test.js +123 -0
- package/test/machine.withdraw_manual.coverage.test.js +185 -0
- package/test/machine.withdraw_manual_cash.coverage.test.js +123 -0
- package/test/request.test.js +325 -0
- package/test/util.storage.errors.test.js +47 -0
- package/test/util.test.js +41 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import test from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
|
|
4
|
+
import virtualBankCashFactory from '../src/machine/deposit/virtual_bank_cash.js'
|
|
5
|
+
|
|
6
|
+
test('virtual_bank_cash covers actions, guards, and services branches', async () => {
|
|
7
|
+
const sent = []
|
|
8
|
+
const request = {
|
|
9
|
+
config: { appSecret: 'secret' },
|
|
10
|
+
send: async (req) => {
|
|
11
|
+
sent.push(req)
|
|
12
|
+
if (req.url === 'payment/v2/vbank_cash/expected/result') {
|
|
13
|
+
return { data: { expectedAmount: 1234 } }
|
|
14
|
+
}
|
|
15
|
+
if (req.url === 'payment/v2/vbank_cash/transaction') {
|
|
16
|
+
return { applyId: 'A-1', status: 'processing' }
|
|
17
|
+
}
|
|
18
|
+
return {}
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const machine = virtualBankCashFactory(request, {
|
|
23
|
+
selectedAmount: 40,
|
|
24
|
+
promotion: { minimumAmount: 50, promotionsNo: 'P-1' },
|
|
25
|
+
paymentDetail: [
|
|
26
|
+
{
|
|
27
|
+
category: 'virtualBank',
|
|
28
|
+
transferType: 'deposit',
|
|
29
|
+
method: 'vbank_cash',
|
|
30
|
+
minimum: 100,
|
|
31
|
+
maximum: 500,
|
|
32
|
+
processing: [{ id: 'processing-1' }],
|
|
33
|
+
virtualBanks: [{ bank: 'A' }],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
category: 'virtualBank',
|
|
37
|
+
transferType: 'withdraw',
|
|
38
|
+
method: 'ignored',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const { actions, guards, services } = machine.options
|
|
44
|
+
const initial = machine.initialState.context
|
|
45
|
+
|
|
46
|
+
const initData = await services.fetchInitData(initial)
|
|
47
|
+
assert.equal(initData.currentPayment.method, 'vbank_cash')
|
|
48
|
+
|
|
49
|
+
const setInitData = actions.setInitData.assignment(initial, { data: initData })
|
|
50
|
+
assert.equal(setInitData.method, 'vbank_cash')
|
|
51
|
+
assert.equal(setInitData.processing.id, 'processing-1')
|
|
52
|
+
assert.equal(setInitData.virtualBanks.bank, 'A')
|
|
53
|
+
assert.equal(setInitData.selectedAmount, 100)
|
|
54
|
+
|
|
55
|
+
const setInitDataWithoutOptional = actions.setInitData.assignment(
|
|
56
|
+
{ paymentDetail: [{ category: 'virtualBank', transferType: 'deposit', method: 'plain', minimum: 10, maximum: 20 }] },
|
|
57
|
+
{ data: { currentPayment: { method: 'plain', minimum: 10, maximum: 20 } } }
|
|
58
|
+
)
|
|
59
|
+
assert.equal(setInitDataWithoutOptional.processing, null)
|
|
60
|
+
assert.equal(setInitDataWithoutOptional.virtualBanks, null)
|
|
61
|
+
|
|
62
|
+
assert.equal(actions.inputAmount.assignment(initial, { data: 222 }).selectedAmount, 222)
|
|
63
|
+
|
|
64
|
+
const fromV2 = actions.setCalculation.assignment(initial, { data: { data: { expectedAmount: 88 } } })
|
|
65
|
+
assert.equal(fromV2.calculation.expectedAmount, 88)
|
|
66
|
+
|
|
67
|
+
const legacy = actions.setCalculation.assignment(initial, { data: { expectedAmount: 77 } })
|
|
68
|
+
assert.equal(legacy.calculation.expectedAmount, 77)
|
|
69
|
+
|
|
70
|
+
assert.equal(actions.setProcessing.assignment(initial, { data: { applyId: 'A-2' } }).processing.applyId, 'A-2')
|
|
71
|
+
assert.equal(actions.clearCalculation.assignment({ calculation: { ok: 1 } }, {}).calculation, null)
|
|
72
|
+
assert.equal(actions.setDepositTime.assignment(initial, { data: '2026-01-01 00:00:00' }).depositTime, '2026-01-01 00:00:00')
|
|
73
|
+
assert.equal(actions.setPromotion.assignment(initial, { data: { promotionsNo: 'P-2' } }).promotion.promotionsNo, 'P-2')
|
|
74
|
+
|
|
75
|
+
assert.equal(guards.isCalculable({ selectedAmount: 100, currentPayment: null }), false)
|
|
76
|
+
assert.equal(guards.isCalculable({ selectedAmount: 99, currentPayment: { minimum: 100, maximum: 500 } }), false)
|
|
77
|
+
assert.equal(guards.isCalculable({ selectedAmount: 501, currentPayment: { minimum: 100, maximum: 500 } }), false)
|
|
78
|
+
assert.equal(guards.isCalculable({ selectedAmount: '120', currentPayment: { minimum: 100, maximum: 500 } }), true)
|
|
79
|
+
|
|
80
|
+
assert.equal(guards.isProcessing({ processing: null }), null)
|
|
81
|
+
assert.equal(guards.isProcessing({ processing: { applyId: 'A-3' } }).applyId, 'A-3')
|
|
82
|
+
|
|
83
|
+
const calcResult = await services.fetchCalculation({ method: 'vbank_cash', selectedAmount: '345', promotion: { promotionsNo: 'P-1' } }, {})
|
|
84
|
+
assert.equal(calcResult.data.expectedAmount, 1234)
|
|
85
|
+
|
|
86
|
+
const submitResult = await services.submitDeposit(
|
|
87
|
+
{
|
|
88
|
+
method: 'vbank_cash',
|
|
89
|
+
selectedAmount: 456,
|
|
90
|
+
depositTime: '2026-01-01 10:00:00',
|
|
91
|
+
promotion: { promotionsNo: 'P-9' },
|
|
92
|
+
},
|
|
93
|
+
{}
|
|
94
|
+
)
|
|
95
|
+
assert.equal(submitResult.applyId, 'A-1')
|
|
96
|
+
|
|
97
|
+
const calcReq = sent.find((entry) => entry.url === 'payment/v2/vbank_cash/expected/result')
|
|
98
|
+
assert.equal(calcReq.params.amount, 345)
|
|
99
|
+
assert.equal(calcReq.params.promotionsNo, 'P-1')
|
|
100
|
+
|
|
101
|
+
const submitReq = sent.find((entry) => entry.url === 'payment/v2/vbank_cash/transaction')
|
|
102
|
+
assert.equal(submitReq.params.amount, 456)
|
|
103
|
+
assert.equal(submitReq.params.depositTime, '2026-01-01 10:00:00')
|
|
104
|
+
assert.equal(submitReq.params.promotionsNo, 'P-9')
|
|
105
|
+
})
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import test from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
|
|
4
|
+
import virtualBankVnFactory from '../src/machine/deposit/virtual_bank_vn.js'
|
|
5
|
+
|
|
6
|
+
test('virtual_bank_vn covers actions, guards, inline checking cond and services', async () => {
|
|
7
|
+
const sent = []
|
|
8
|
+
const request = {
|
|
9
|
+
config: { appSecret: 'secret' },
|
|
10
|
+
send: async (req) => {
|
|
11
|
+
sent.push(req)
|
|
12
|
+
if (req.url === 'payment/v2/paymentDetail') {
|
|
13
|
+
return [
|
|
14
|
+
{ category: 'other', method: 'ignored' },
|
|
15
|
+
{
|
|
16
|
+
category: 'virtualBank',
|
|
17
|
+
method: 'virtual_bank_vn',
|
|
18
|
+
minimum: 100,
|
|
19
|
+
maximum: 500,
|
|
20
|
+
processing: [{ applyId: 'P-1' }],
|
|
21
|
+
virtualBanks: [{ bankCode: 'VCB' }],
|
|
22
|
+
},
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
if (req.url === 'payment/v2/virtual_bank_vn/expected/result') {
|
|
26
|
+
return { data: { expectedAmount: 888 } }
|
|
27
|
+
}
|
|
28
|
+
if (req.url === 'payment/v2/virtual_bank_vn/transaction') {
|
|
29
|
+
return { applyId: 'TX-1', status: 'processing' }
|
|
30
|
+
}
|
|
31
|
+
return {}
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const machine = virtualBankVnFactory(request)
|
|
36
|
+
const { actions, guards, services } = machine.options
|
|
37
|
+
const initial = machine.initialState.context
|
|
38
|
+
|
|
39
|
+
const paymentDetail = await services.fetchPaymentDetail(initial)
|
|
40
|
+
assert.equal(paymentDetail.length, 2)
|
|
41
|
+
|
|
42
|
+
const initData = actions.setInitData.assignment(initial, { data: paymentDetail })
|
|
43
|
+
assert.equal(initData.paymentDetail.length, 2)
|
|
44
|
+
assert.equal(initData.currentPayment.method, 'virtual_bank_vn')
|
|
45
|
+
assert.equal(initData.method, 'virtual_bank_vn')
|
|
46
|
+
assert.equal(initData.processing.applyId, 'P-1')
|
|
47
|
+
assert.equal(initData.virtualBanks.bankCode, 'VCB')
|
|
48
|
+
|
|
49
|
+
const initEmpty = actions.setInitData.assignment(initial, { data: [] })
|
|
50
|
+
assert.equal(initEmpty.currentPayment, undefined)
|
|
51
|
+
assert.equal(initEmpty.method, undefined)
|
|
52
|
+
assert.equal(initEmpty.processing, undefined)
|
|
53
|
+
assert.equal(initEmpty.virtualBanks, undefined)
|
|
54
|
+
|
|
55
|
+
assert.equal(actions.setAmount.assignment(initial, { data: 222 }).amount, 222)
|
|
56
|
+
|
|
57
|
+
const calculationV2 = actions.setCalculation.assignment(initial, { data: { data: { expectedAmount: 777 } } })
|
|
58
|
+
assert.equal(calculationV2.calculation.expectedAmount, 777)
|
|
59
|
+
|
|
60
|
+
const calculationLegacy = actions.setCalculation.assignment(initial, { data: { expectedAmount: 666 } })
|
|
61
|
+
assert.equal(calculationLegacy.calculation.expectedAmount, 666)
|
|
62
|
+
|
|
63
|
+
assert.equal(actions.setProcessing.assignment(initial, { data: { applyId: 'P-2' } }).processing.applyId, 'P-2')
|
|
64
|
+
assert.equal(actions.clearCalculation.assignment({ calculation: { ok: 1 } }, {}).calculation, null)
|
|
65
|
+
assert.equal(actions.setDepositTime.assignment(initial, { data: '2026-02-01 10:00:00' }).depositTime, '2026-02-01 10:00:00')
|
|
66
|
+
assert.equal(actions.setPromotion.assignment(initial, { data: { activityNo: 'A-1' } }).promotion.activityNo, 'A-1')
|
|
67
|
+
|
|
68
|
+
assert.equal(guards.isCalculable({ amount: 100, currentPayment: { minimum: 100, maximum: 500 } }), true)
|
|
69
|
+
assert.equal(guards.isCalculable({ amount: 99, currentPayment: { minimum: 100, maximum: 500 } }), false)
|
|
70
|
+
assert.equal(guards.isCalculable({ amount: 501, currentPayment: { minimum: 100, maximum: 500 } }), false)
|
|
71
|
+
|
|
72
|
+
assert.equal(guards.isCalculated({ calculation: null }), null)
|
|
73
|
+
assert.equal(guards.isCalculated({ calculation: { expectedAmount: 1 } }).expectedAmount, 1)
|
|
74
|
+
assert.equal(guards.isProcessing({ processing: null }), null)
|
|
75
|
+
assert.equal(guards.isProcessing({ processing: { applyId: 'P-3' } }).applyId, 'P-3')
|
|
76
|
+
|
|
77
|
+
const checkingCond = machine.config.states.checking.always[0].cond
|
|
78
|
+
assert.equal(checkingCond({ calculation: { expectedAmount: 1 }, promotion: { promotionsNo: 'x', activityNo: 'y' } }), true)
|
|
79
|
+
assert.equal(checkingCond({ calculation: { expectedAmount: 1 }, promotion: { promotionsNo: 'none', activityNo: 'y' } }), false)
|
|
80
|
+
assert.equal(checkingCond({ calculation: { expectedAmount: 1 }, promotion: { promotionsNo: 'x', activityNo: 'none' } }), false)
|
|
81
|
+
assert.equal(checkingCond({ calculation: null, promotion: { promotionsNo: 'x', activityNo: 'y' } }), false)
|
|
82
|
+
|
|
83
|
+
const calcResult = await services.fetchCalculation({ method: 'virtual_bank_vn', amount: '333', promotion: { activityNo: 'A-9' } })
|
|
84
|
+
assert.equal(calcResult.data.expectedAmount, 888)
|
|
85
|
+
|
|
86
|
+
const submitResult = await services.submitDeposit({
|
|
87
|
+
method: 'virtual_bank_vn',
|
|
88
|
+
amount: 444,
|
|
89
|
+
depositTime: '2026-02-01 10:00:00',
|
|
90
|
+
promotion: { activityNo: 'A-8' },
|
|
91
|
+
})
|
|
92
|
+
assert.equal(submitResult.applyId, 'TX-1')
|
|
93
|
+
|
|
94
|
+
const fetchReq = sent.find((entry) => entry.url === 'payment/v2/paymentDetail')
|
|
95
|
+
assert.equal(fetchReq.params.transferType, 'DEPOSIT')
|
|
96
|
+
|
|
97
|
+
const calcReq = sent.find((entry) => entry.url === 'payment/v2/virtual_bank_vn/expected/result')
|
|
98
|
+
assert.equal(calcReq.params.amount, 333)
|
|
99
|
+
assert.equal(calcReq.params.promotionsNo, 'A-9')
|
|
100
|
+
|
|
101
|
+
const submitReq = sent.find((entry) => entry.url === 'payment/v2/virtual_bank_vn/transaction')
|
|
102
|
+
assert.equal(submitReq.params.amount, 444)
|
|
103
|
+
assert.equal(submitReq.params.depositTime, '2026-02-01 10:00:00')
|
|
104
|
+
assert.equal(submitReq.params.promotionsNo, 'A-8')
|
|
105
|
+
})
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import test from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
|
|
4
|
+
import vpayFactory from '../src/machine/deposit/vpay.js'
|
|
5
|
+
|
|
6
|
+
test('vpay covers actions, guards, inline cond and services', async () => {
|
|
7
|
+
const sent = []
|
|
8
|
+
const request = {
|
|
9
|
+
config: { appSecret: 'app-secret' },
|
|
10
|
+
send: async (req) => {
|
|
11
|
+
sent.push(req)
|
|
12
|
+
if (req.url === 'payment/v2/paymentInfo') {
|
|
13
|
+
return {
|
|
14
|
+
bankInfo: [
|
|
15
|
+
{ bindingType: 'CRYPTO', id: 1 },
|
|
16
|
+
{ bindingType: 'EWALLET', id: 2 },
|
|
17
|
+
{ bindingType: 'BANK', id: 3 },
|
|
18
|
+
],
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (req.url === 'getConfig') {
|
|
22
|
+
return { config: 'eyJib251c1ByZXZpZXdFbmFibGUiOnRydWV9' }
|
|
23
|
+
}
|
|
24
|
+
if (req.url === 'payment/v2/paymentDetail') {
|
|
25
|
+
return [{ method: 'ignored' }, { method: 'vpay', optional: [100], minimum: 50, maximum: 500, grandTotalEnable: 1 }]
|
|
26
|
+
}
|
|
27
|
+
if (req.url === 'payment/v2/amb/getBankList') {
|
|
28
|
+
return { data: [{ code: 'B1' }] }
|
|
29
|
+
}
|
|
30
|
+
if (req.url === 'payment/v2/vpay/checkTransaction') {
|
|
31
|
+
return { qrcode: 'QR-OLD', amount: 321, vpayId: 'VP-OLD' }
|
|
32
|
+
}
|
|
33
|
+
if (req.url === 'payment/v2/vpay/bonus/preview') {
|
|
34
|
+
return [{ bonus: 8 }]
|
|
35
|
+
}
|
|
36
|
+
if (req.url === 'payment/v2/vpay/transaction') {
|
|
37
|
+
return { qrcode: 'QR-NEW', amount: 222, vpayId: 'VP-NEW' }
|
|
38
|
+
}
|
|
39
|
+
if (req.url === 'payment/v2/vpay/expected/result') {
|
|
40
|
+
return { data: { expectedAmount: 111 } }
|
|
41
|
+
}
|
|
42
|
+
return {}
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
global.window = { atob: (value) => Buffer.from(value, 'base64').toString('utf8') }
|
|
47
|
+
|
|
48
|
+
const machine = vpayFactory(request)
|
|
49
|
+
const { actions, guards, services } = machine.options
|
|
50
|
+
const initial = machine.initialState.context
|
|
51
|
+
|
|
52
|
+
const checkingCond = machine.config.states.checking.always[0].cond
|
|
53
|
+
assert.equal(checkingCond({ siteConfig: { bonusPreviewEnable: true }, promotion: { activityNo: 'A1' } }), true)
|
|
54
|
+
assert.equal(checkingCond({ siteConfig: { bonusPreviewEnable: false }, promotion: { activityNo: 'A1' } }), false)
|
|
55
|
+
assert.equal(checkingCond({ siteConfig: { bonusPreviewEnable: true }, promotion: { activityNo: 'none' } }), false)
|
|
56
|
+
|
|
57
|
+
assert.equal(actions.setUserAccount.assignment(initial, { data: [{ account: 'u1' }] }).userAccount.account, 'u1')
|
|
58
|
+
assert.equal(actions.setBonusPreview.assignment(initial, { data: [{ bonus: 7 }] }).bonusPreviewData[0].bonus, 7)
|
|
59
|
+
|
|
60
|
+
const order = actions.setOrder.assignment(initial, { data: { amount: 99, qrcode: 'Q1', vpayId: 'V1' } })
|
|
61
|
+
assert.equal(order.qrcode, 'Q1')
|
|
62
|
+
assert.equal(order.vpayId, 'V1')
|
|
63
|
+
assert.equal(order.calculatedAmount, 99)
|
|
64
|
+
|
|
65
|
+
const previousOrder = actions.setPreviousOrder.assignment(initial, { data: { order: { amount: 88, qrcode: 'Q2', vpayId: 'V2' } } })
|
|
66
|
+
assert.equal(previousOrder.qrcode, 'Q2')
|
|
67
|
+
assert.equal(previousOrder.vpayId, 'V2')
|
|
68
|
+
assert.equal(previousOrder.calculatedAmount, 88)
|
|
69
|
+
|
|
70
|
+
const initFromData = actions.setInitialization.assignment(initial, {
|
|
71
|
+
data: {
|
|
72
|
+
siteConfig: { bonusPreviewEnable: true },
|
|
73
|
+
housePayment: { optional: [100, 200], minimum: 50, maximum: 500, grandTotalEnable: 1 },
|
|
74
|
+
bankList: { data: [{ code: 'B1' }] },
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
assert.equal(initFromData.bankList[0].code, 'B1')
|
|
78
|
+
|
|
79
|
+
const initFromArray = actions.setInitialization.assignment(initial, {
|
|
80
|
+
data: {
|
|
81
|
+
siteConfig: { bonusPreviewEnable: true },
|
|
82
|
+
housePayment: { optional: [300], minimum: 10, maximum: 20, grandTotalEnable: 0 },
|
|
83
|
+
bankList: [{ code: 'B2' }],
|
|
84
|
+
},
|
|
85
|
+
})
|
|
86
|
+
assert.equal(initFromArray.bankList[0].code, 'B2')
|
|
87
|
+
|
|
88
|
+
assert.equal(actions.setPromotion.assignment(initial, { data: { activityNo: 'P1' } }).promotion.activityNo, 'P1')
|
|
89
|
+
assert.equal(actions.addAmount.assignment({ amount: 200, maximum: 250 }, { data: 80 }).amount, 250)
|
|
90
|
+
assert.equal(actions.setAmount.assignment(initial, { data: 333 }).amount, 333)
|
|
91
|
+
|
|
92
|
+
const calcFromV2 = actions.setCalculation.assignment(initial, { data: { data: { expectedAmount: 5 } } })
|
|
93
|
+
assert.equal(calcFromV2.calculation.expectedAmount, 5)
|
|
94
|
+
|
|
95
|
+
const calcLegacy = actions.setCalculation.assignment(initial, { data: { expectedAmount: 6 } })
|
|
96
|
+
assert.equal(calcLegacy.calculation.expectedAmount, 6)
|
|
97
|
+
|
|
98
|
+
assert.equal(actions.clearCalculation.assignment({ calculation: { ok: 1 } }, {}).calculation, null)
|
|
99
|
+
const reset = actions.reset.assignment()
|
|
100
|
+
assert.equal(reset.amount, 0)
|
|
101
|
+
assert.equal(reset.calculation, null)
|
|
102
|
+
|
|
103
|
+
assert.equal(guards.hasUserAccount(initial, { data: [] }), undefined)
|
|
104
|
+
assert.equal(guards.hasUserAccount(initial, { data: [{ id: 9 }] }).id, 9)
|
|
105
|
+
assert.equal(guards.hasPreviousOrder(initial, { data: { order: {} } }), undefined)
|
|
106
|
+
assert.equal(guards.hasPreviousOrder(initial, { data: { order: { qrcode: 'X' } } }), 'X')
|
|
107
|
+
assert.equal(guards.isGrandTotalEnable({ grandTotalEnable: 1 }), true)
|
|
108
|
+
assert.equal(guards.isGrandTotalEnable({ grandTotalEnable: 0 }), false)
|
|
109
|
+
|
|
110
|
+
const filtered = await services.fetchPaymentInfo(initial)
|
|
111
|
+
assert.equal(filtered.length, 1)
|
|
112
|
+
assert.equal(filtered[0].id, 3)
|
|
113
|
+
|
|
114
|
+
const initialized = await services.initialize({ method: 'vpay' })
|
|
115
|
+
assert.equal(initialized.siteConfig.bonusPreviewEnable, true)
|
|
116
|
+
assert.equal(initialized.housePayment.method, 'vpay')
|
|
117
|
+
assert.equal(initialized.bankList.data[0].code, 'B1')
|
|
118
|
+
assert.equal(initialized.order.qrcode, 'QR-OLD')
|
|
119
|
+
|
|
120
|
+
const bonusPreview = await services.fetchBonusPreview({ method: 'vpay', promotion: { activityNo: 'P100' } })
|
|
121
|
+
assert.equal(bonusPreview[0].bonus, 8)
|
|
122
|
+
|
|
123
|
+
const submitResult = await services.submitDeposit({ method: 'vpay', amount: 444, promotion: { activityNo: 'P9' } })
|
|
124
|
+
assert.equal(submitResult.vpayId, 'VP-NEW')
|
|
125
|
+
|
|
126
|
+
const calcResult = await services.fetchCalculation({ method: 'vpay', amount: '45', promotion: { activityNo: 'P8' } })
|
|
127
|
+
assert.equal(calcResult.data.expectedAmount, 111)
|
|
128
|
+
|
|
129
|
+
const bonusReq = sent.find((entry) => entry.url === 'payment/v2/vpay/bonus/preview')
|
|
130
|
+
assert.equal(bonusReq.params.promotionsNo, 'P100')
|
|
131
|
+
|
|
132
|
+
const submitReq = sent.find((entry) => entry.url === 'payment/v2/vpay/transaction')
|
|
133
|
+
assert.equal(submitReq.params.amount, 444)
|
|
134
|
+
assert.equal(submitReq.params.promotionsNo, 'P9')
|
|
135
|
+
|
|
136
|
+
const calcReq = sent.find((entry) => entry.url === 'payment/v2/vpay/expected/result')
|
|
137
|
+
assert.equal(calcReq.params.amount, 45)
|
|
138
|
+
assert.equal(calcReq.params.promotionsNo, 'P8')
|
|
139
|
+
|
|
140
|
+
const paymentDetailReq = sent.find((entry) => entry.url === 'payment/v2/paymentDetail')
|
|
141
|
+
assert.equal(paymentDetailReq.params.transferType, 'DEPOSIT')
|
|
142
|
+
})
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import test from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
|
|
4
|
+
import withdrawCryptoCashFactory from '../src/machine/withdraw/withdraw_crypto_cash.js'
|
|
5
|
+
|
|
6
|
+
test('withdraw_crypto_cash covers actions, guards and services including otp flow', async () => {
|
|
7
|
+
const sent = []
|
|
8
|
+
const request = {
|
|
9
|
+
send: async (req) => {
|
|
10
|
+
sent.push(req)
|
|
11
|
+
if (req.url === 'payment/v2/withdrawRule') {
|
|
12
|
+
return { balance: 900 }
|
|
13
|
+
}
|
|
14
|
+
if (req.url === 'payment/v2/pendingOrder') {
|
|
15
|
+
return [{ applyId: 'P-1' }]
|
|
16
|
+
}
|
|
17
|
+
if (req.url === 'payment/v2/withdraw_crypto_cash/expected/result') {
|
|
18
|
+
return { data: { fee: 1 } }
|
|
19
|
+
}
|
|
20
|
+
if (req.url === 'payment/v2/withdraw_crypto_cash/transaction') {
|
|
21
|
+
return { status: 'otp-verifying', requestId: 'RID-1', target: 'phone', ttl: 60 }
|
|
22
|
+
}
|
|
23
|
+
if (req.url === '/otpsso/reset') {
|
|
24
|
+
return { requestId: 'RID-2', ttl: 30, target: 'phone' }
|
|
25
|
+
}
|
|
26
|
+
if (req.url === '/otpsso/acknowledge') {
|
|
27
|
+
return { ok: true }
|
|
28
|
+
}
|
|
29
|
+
return {}
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const machine = withdrawCryptoCashFactory(request, {
|
|
34
|
+
paymentDetail: [
|
|
35
|
+
{
|
|
36
|
+
transferType: 'withdraw',
|
|
37
|
+
category: 'crypto',
|
|
38
|
+
method: 'withdraw_crypto_cash',
|
|
39
|
+
channel: 'USDT',
|
|
40
|
+
minimum: 100,
|
|
41
|
+
maximum: 1000,
|
|
42
|
+
networkName: ['TRC20', 'ERC20'],
|
|
43
|
+
networkOptional: ['TRON', 'ETH'],
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const { actions, guards, services } = machine.options
|
|
49
|
+
const initial = machine.initialState.context
|
|
50
|
+
|
|
51
|
+
const initData = actions.setInitData.assignment(initial, {
|
|
52
|
+
data: {
|
|
53
|
+
withdrawRule: { balance: 900 },
|
|
54
|
+
processing: { applyId: 'P-1' },
|
|
55
|
+
},
|
|
56
|
+
})
|
|
57
|
+
assert.equal(initData.withdrawRule.balance, 900)
|
|
58
|
+
assert.equal(initData.selectedCrypto.method, 'withdraw_crypto_cash')
|
|
59
|
+
assert.equal(initData.networks.length, 2)
|
|
60
|
+
assert.equal(initData.selectedNetwork.value, 'TRC20')
|
|
61
|
+
assert.equal(initData.processing.applyId, 'P-1')
|
|
62
|
+
|
|
63
|
+
assert.equal(actions.setNetwork.assignment(initial, { data: { value: 'ERC20' } }).selectedNetwork.value, 'ERC20')
|
|
64
|
+
assert.equal(actions.setAddress.assignment(initial, { data: 'ADDR' }).address, 'ADDR')
|
|
65
|
+
assert.equal(actions.setAmount.assignment(initial, { data: 456 }).selectedAmount, 456)
|
|
66
|
+
|
|
67
|
+
assert.equal(actions.setCalculation.assignment(initial, { data: { data: { fee: 2 } } }).calculation.fee, 2)
|
|
68
|
+
assert.equal(actions.setCalculation.assignment(initial, { data: { fee: 3 } }).calculation.fee, 3)
|
|
69
|
+
|
|
70
|
+
assert.equal(actions.resetCharge.assignment(initial, {}).charge, null)
|
|
71
|
+
assert.equal(actions.setTransaction.assignment(initial, { data: { realAmount: 321 } }).realAmount, 321)
|
|
72
|
+
|
|
73
|
+
const otpData = actions.setOtp.assignment(initial, {
|
|
74
|
+
data: { requestId: 'RID-1', status: 'otp-verifying', target: 'phone', ttl: 60 },
|
|
75
|
+
})
|
|
76
|
+
assert.equal(otpData.requestId, 'RID-1')
|
|
77
|
+
assert.equal(otpData.status, 'otp-verifying')
|
|
78
|
+
assert.equal(otpData.target, 'phone')
|
|
79
|
+
assert.equal(otpData.ttl, 60)
|
|
80
|
+
|
|
81
|
+
assert.equal(actions.decreaseTtl.assignment({ ttl: 2 }, {}).ttl, 1)
|
|
82
|
+
assert.equal(actions.decreaseTtl.assignment({ ttl: 0 }, {}).ttl, 0)
|
|
83
|
+
|
|
84
|
+
const verification = actions.setVerificationData.assignment(initial, {
|
|
85
|
+
data: { requestId: 'RID-2', ttl: 30, target: 'email' },
|
|
86
|
+
})
|
|
87
|
+
assert.equal(verification.requestId, 'RID-2')
|
|
88
|
+
assert.equal(verification.ttl, 30)
|
|
89
|
+
assert.equal(verification.target, 'email')
|
|
90
|
+
|
|
91
|
+
assert.equal(actions.setAttachmentType.assignment(initial, { data: 'withdraw' }).attachmentType, 'withdraw')
|
|
92
|
+
assert.equal(actions.setProcessing.assignment(initial, { data: { applyId: 'P-2' } }).processing.applyId, 'P-2')
|
|
93
|
+
|
|
94
|
+
assert.equal(guards.isProcessing({ processing: null }), null)
|
|
95
|
+
assert.equal(guards.isProcessing({ processing: { applyId: 'P-1' } }).applyId, 'P-1')
|
|
96
|
+
|
|
97
|
+
assert.equal(
|
|
98
|
+
guards.isCalculable({
|
|
99
|
+
withdrawRule: { balance: 900 },
|
|
100
|
+
selectedCrypto: { minimum: 100, maximum: 1000 },
|
|
101
|
+
selectedNetwork: { value: 'TRC20' },
|
|
102
|
+
selectedAmount: 800,
|
|
103
|
+
}),
|
|
104
|
+
true
|
|
105
|
+
)
|
|
106
|
+
assert.equal(
|
|
107
|
+
guards.isCalculable({
|
|
108
|
+
withdrawRule: { balance: 300 },
|
|
109
|
+
selectedCrypto: { minimum: 100, maximum: 1000 },
|
|
110
|
+
selectedNetwork: { value: 'TRC20' },
|
|
111
|
+
selectedAmount: 350,
|
|
112
|
+
}),
|
|
113
|
+
false
|
|
114
|
+
)
|
|
115
|
+
assert.equal(guards.isOtpRequired({}, { data: { status: 'otp-verifying' } }), true)
|
|
116
|
+
assert.equal(guards.isOtpRequired({}, { data: { status: 'done' } }), false)
|
|
117
|
+
|
|
118
|
+
const fetchedInit = await services.fetchInitData(initial)
|
|
119
|
+
assert.equal(fetchedInit.withdrawRule.balance, 900)
|
|
120
|
+
assert.equal(fetchedInit.processing.applyId, 'P-1')
|
|
121
|
+
|
|
122
|
+
const rule = await services.fetchWithdrawRule(initial)
|
|
123
|
+
assert.equal(rule.balance, 900)
|
|
124
|
+
|
|
125
|
+
const calc = await services.fetchCalculation({
|
|
126
|
+
selectedCrypto: { method: 'withdraw_crypto_cash' },
|
|
127
|
+
selectedNetwork: { value: 'TRC20' },
|
|
128
|
+
selectedAmount: 222,
|
|
129
|
+
})
|
|
130
|
+
assert.equal(calc.data.fee, 1)
|
|
131
|
+
|
|
132
|
+
const submit = await services.submitWithdraw({
|
|
133
|
+
selectedCrypto: { method: 'withdraw_crypto_cash', channel: 'USDT' },
|
|
134
|
+
selectedNetwork: { value: 'TRC20' },
|
|
135
|
+
address: 'ADDR',
|
|
136
|
+
selectedAmount: 333,
|
|
137
|
+
})
|
|
138
|
+
assert.equal(submit.status, 'otp-verifying')
|
|
139
|
+
|
|
140
|
+
const reset = await services.resetOtp({ requestId: 'RID-1', target: 'phone' })
|
|
141
|
+
assert.equal(reset.requestId, 'RID-2')
|
|
142
|
+
|
|
143
|
+
const ack = await services.acknowledge({ requestId: 'RID-2', target: 'phone' }, { data: '123456' })
|
|
144
|
+
assert.equal(ack.ok, true)
|
|
145
|
+
|
|
146
|
+
const ruleReq = sent.find((entry) => entry.url === 'payment/v2/withdrawRule')
|
|
147
|
+
assert.equal(ruleReq.params.walletType, 'CASH')
|
|
148
|
+
|
|
149
|
+
const pendingReq = sent.find((entry) => entry.url === 'payment/v2/pendingOrder')
|
|
150
|
+
assert.equal(pendingReq.params.transferType, 'WITHDRAW')
|
|
151
|
+
|
|
152
|
+
const calcReq = sent.find((entry) => entry.url === 'payment/v2/withdraw_crypto_cash/expected/result')
|
|
153
|
+
assert.equal(calcReq.params.amount, 222)
|
|
154
|
+
assert.equal(calcReq.params.cryptoNetwork, 'TRC20')
|
|
155
|
+
|
|
156
|
+
const submitReq = sent.find((entry) => entry.url === 'payment/v2/withdraw_crypto_cash/transaction')
|
|
157
|
+
assert.equal(submitReq.params.amount, 333)
|
|
158
|
+
assert.equal(submitReq.params.cryptoCurrency, 'USDT')
|
|
159
|
+
assert.equal(submitReq.params.targetAddress, 'ADDR')
|
|
160
|
+
|
|
161
|
+
const resetReq = sent.find((entry) => entry.url === '/otpsso/reset')
|
|
162
|
+
assert.equal(resetReq.params.requestId, 'RID-1')
|
|
163
|
+
|
|
164
|
+
const ackReq = sent.find((entry) => entry.url === '/otpsso/acknowledge')
|
|
165
|
+
assert.equal(ackReq.params.code, '123456')
|
|
166
|
+
})
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import test from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
|
|
4
|
+
import withdrawKrwayFactory from '../src/machine/withdraw/withdraw_krway.js'
|
|
5
|
+
|
|
6
|
+
test('withdraw_krway covers actions, guards and services branches', async () => {
|
|
7
|
+
const sent = []
|
|
8
|
+
const request = {
|
|
9
|
+
config: { appSecret: 'secret' },
|
|
10
|
+
send: async (req) => {
|
|
11
|
+
sent.push(req)
|
|
12
|
+
if (req.url === 'payment/v2/paymentDetail') {
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
method: 'krway',
|
|
16
|
+
minimum: 100,
|
|
17
|
+
maximum: 5000,
|
|
18
|
+
optional: [100, 200],
|
|
19
|
+
processing: [{ applyId: 'P-1' }],
|
|
20
|
+
},
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
if (req.url === 'payment/v2/paymentInfo') {
|
|
24
|
+
return { bankInfo: [{ bankCode: 'KB', accountNumber: '123', branch: 'SE', holderName: 'Tony' }] }
|
|
25
|
+
}
|
|
26
|
+
if (req.url === 'payment/v2/withdrawRule') {
|
|
27
|
+
return { enableWithdraw: true, balance: 900 }
|
|
28
|
+
}
|
|
29
|
+
if (req.url === 'payment/v2/krway/transaction') {
|
|
30
|
+
return { applyId: 'A-1', balance: 800, realAmount: 100, charge: 1 }
|
|
31
|
+
}
|
|
32
|
+
if (req.url === 'payment/v2/withdrawCheck') {
|
|
33
|
+
return { passDepositeLimit: true, passWithdrawCooldownTime: true, withdrawInServiceTime: true }
|
|
34
|
+
}
|
|
35
|
+
return {}
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const machine = withdrawKrwayFactory(request)
|
|
40
|
+
const { actions, guards, services } = machine.options
|
|
41
|
+
const setWithdrawCheck = machine.config.states.withdrawCheck.invoke.onDone[0].actions.assignment
|
|
42
|
+
const initial = machine.initialState.context
|
|
43
|
+
|
|
44
|
+
const paymentData = actions.setPaymentData.assignment(initial, {
|
|
45
|
+
data: {
|
|
46
|
+
paymentDetail: [{ minimum: 100, maximum: 5000, optional: [100], processing: [{ applyId: 'P-1' }] }],
|
|
47
|
+
bankInfo: [{ bankCode: 'KB' }],
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
assert.equal(paymentData.bank.bankCode, 'KB')
|
|
51
|
+
assert.equal(paymentData.minimum, 100)
|
|
52
|
+
assert.equal(paymentData.maximum, 5000)
|
|
53
|
+
assert.equal(paymentData.options[0], 100)
|
|
54
|
+
const paymentDataFallback = actions.setPaymentData.assignment(initial, {
|
|
55
|
+
data: {
|
|
56
|
+
paymentDetail: [],
|
|
57
|
+
bankInfo: [],
|
|
58
|
+
},
|
|
59
|
+
})
|
|
60
|
+
assert.equal(paymentDataFallback.bank, undefined)
|
|
61
|
+
assert.equal(paymentDataFallback.minimum, undefined)
|
|
62
|
+
|
|
63
|
+
const condition = actions.updateWithdrawCondition.assignment(initial, { data: { enableWithdraw: true, balance: 300 } })
|
|
64
|
+
assert.equal(condition.enableWithdraw, true)
|
|
65
|
+
assert.equal(condition.balance, 300)
|
|
66
|
+
|
|
67
|
+
assert.equal(actions.addAmount.assignment({ amount: null }, { data: 5 }).amount, 5)
|
|
68
|
+
assert.equal(actions.addAmount.assignment({ amount: '10.5' }, { data: '0.5' }).amount, 11)
|
|
69
|
+
assert.equal(actions.setAmount.assignment(initial, { data: '123.45' }).amount, 123.45)
|
|
70
|
+
assert.equal(actions.clearAmount.assignment(initial, {}).amount, null)
|
|
71
|
+
|
|
72
|
+
const result = actions.setResult.assignment(initial, { data: { applyId: 'A-2', balance: 700, realAmount: 50, charge: 2 } })
|
|
73
|
+
assert.equal(result.applyId, 'A-2')
|
|
74
|
+
assert.equal(result.balance, 700)
|
|
75
|
+
assert.equal(result.realAmount, 50)
|
|
76
|
+
assert.equal(result.charge, 2)
|
|
77
|
+
|
|
78
|
+
assert.equal(guards.haveProcessing({ paymentDetail: [{ processing: [{ id: 1 }] }] }), true)
|
|
79
|
+
assert.equal(guards.haveProcessing({ paymentDetail: [{ processing: [] }] }), false)
|
|
80
|
+
|
|
81
|
+
assert.equal(guards.isSubmittable({ amount: 1 }), true)
|
|
82
|
+
assert.equal(guards.isSubmittable({ amount: 0 }), false)
|
|
83
|
+
|
|
84
|
+
assert.equal(guards.isNotWithdrawable({ balance: 50, enableWithdraw: true, paymentDetail: [{ minimum: 100 }] }), true)
|
|
85
|
+
assert.equal(guards.isNotWithdrawable({ balance: 150, enableWithdraw: false, paymentDetail: [{ minimum: 100 }] }), true)
|
|
86
|
+
assert.equal(guards.isNotWithdrawable({ balance: 150, enableWithdraw: true, paymentDetail: [{ minimum: 100 }] }), false)
|
|
87
|
+
|
|
88
|
+
assert.equal(guards.isNotWithdrawMinDepositAmount({ withdrawCheck: { passDepositeLimit: false } }), true)
|
|
89
|
+
assert.equal(guards.isNotWithdrawMinDepositAmount({ withdrawCheck: { passDepositeLimit: true } }), false)
|
|
90
|
+
assert.equal(guards.isNotWithdrawMinDepositAmount({ withdrawCheck: null }), true)
|
|
91
|
+
assert.equal(guards.isPassWithdrawCooldownTime({ withdrawCheck: { passWithdrawCooldownTime: false } }), true)
|
|
92
|
+
assert.equal(guards.isPassWithdrawCooldownTime({ withdrawCheck: { passWithdrawCooldownTime: true } }), false)
|
|
93
|
+
assert.equal(guards.isPassWithdrawCooldownTime({ withdrawCheck: null }), true)
|
|
94
|
+
assert.equal(guards.isNotWIthdrawServiceTime({ withdrawCheck: { withdrawInServiceTime: false } }), true)
|
|
95
|
+
assert.equal(guards.isNotWIthdrawServiceTime({ withdrawCheck: { withdrawInServiceTime: true } }), false)
|
|
96
|
+
assert.equal(guards.isNotWIthdrawServiceTime({ withdrawCheck: null }), true)
|
|
97
|
+
|
|
98
|
+
const fetched = await services.fetchPaymentDetail(initial)
|
|
99
|
+
assert.equal(fetched.paymentDetail[0].method, 'krway')
|
|
100
|
+
assert.equal(fetched.bankInfo[0].bankCode, 'KB')
|
|
101
|
+
|
|
102
|
+
const rules = await services.fetchWithdrawRules(initial)
|
|
103
|
+
assert.equal(rules.enableWithdraw, true)
|
|
104
|
+
|
|
105
|
+
const submit = await services.submitWithdraw({
|
|
106
|
+
paymentDetail: [{ method: 'krway' }],
|
|
107
|
+
amount: 100,
|
|
108
|
+
bank: { bankCode: 'KB', accountNumber: '123', branch: 'SE', holderName: 'Tony' },
|
|
109
|
+
})
|
|
110
|
+
assert.equal(submit.applyId, 'A-1')
|
|
111
|
+
|
|
112
|
+
const check = await services.withdrawCheck(initial)
|
|
113
|
+
assert.equal(check.passDepositeLimit, true)
|
|
114
|
+
assert.equal(setWithdrawCheck(initial, { data: { passDepositeLimit: true } }).withdrawCheck.passDepositeLimit, true)
|
|
115
|
+
|
|
116
|
+
const ruleReq = sent.find((entry) => entry.url === 'payment/v2/withdrawRule')
|
|
117
|
+
assert.equal(ruleReq.params.walletType, 'CASH')
|
|
118
|
+
|
|
119
|
+
const submitReq = sent.find((entry) => entry.url === 'payment/v2/krway/transaction')
|
|
120
|
+
assert.equal(submitReq.params.amount, 100)
|
|
121
|
+
assert.equal(submitReq.params.applyerBankCode, 'KB')
|
|
122
|
+
assert.equal(submitReq.params.applyerAccountNumber, '123')
|
|
123
|
+
})
|