@jetthai/cuora 2.0.0-beta.1 → 2.0.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/.claude/commands/sync-ai-prompts.md +93 -0
- package/.claude/settings.local.json +23 -0
- package/.github/copilot-instructions.md +405 -0
- package/.husky/post-checkout +32 -0
- package/.husky/pre-commit +1 -3
- package/.husky/pre-push +36 -0
- package/AGENTS.md +405 -0
- package/AI_PROMPT_SOURCE.md +403 -0
- package/CHANGELOG.md +274 -3
- package/CLAUDE.md +405 -0
- package/GEMINI.md +405 -0
- package/README.md +299 -15
- package/docs/kibana/crypto-way-deposit-amount-bug-analysis.md +1003 -0
- package/docs/kibana/play-providerId-error.md +202 -0
- package/docs/kibana/play-selectedWalletType.md +1 -0
- package/docs/kibana/play-selectedWalletType_2.md +1 -0
- package/docs/kibana/play-selectedWalletType_analysis.md +565 -0
- package/package.json +3 -3
- package/scripts/auto-version.js +68 -0
- package/scripts/auto-version.sh +33 -0
- package/scripts/branch-auto-npm-publish.js +29 -0
- package/scripts/check-version.sh +36 -0
- package/scripts/clean-tags.sh +84 -0
- package/src/api/account.js +0 -1
- package/src/api/activity.js +22 -37
- package/src/api/auth.js +5 -36
- package/src/api/common.js +5 -3
- package/src/api/game.js +0 -10
- package/src/api/payment.js +17 -55
- package/src/api/user.js +10 -16
- package/src/index.js +2 -2
- package/src/machine/activity/activity_cash.js +84 -36
- package/src/machine/activity/cash_rain_activity.js +0 -1
- package/src/machine/activity/continue_deposit_activity.js +0 -1
- package/src/machine/activity/deposit_activity.js +0 -1
- package/src/machine/activity/diamond_shop_activity_cash.js +0 -8
- package/src/machine/activity/fafafa_activity.js +0 -11
- package/src/machine/activity/friend_invite_friends_activity.js +8 -7
- package/src/machine/activity/index.js +0 -12
- package/src/machine/activity/instant_rebate_activity.js +0 -1
- package/src/machine/activity/jackpot.js +0 -1
- package/src/machine/activity/otp_verified_activity.js +0 -1
- package/src/machine/activity/ranking_activity.js +0 -1
- package/src/machine/activity/roulette_activity_v2.js +0 -1
- package/src/machine/activity/sign_in_activity.js +0 -1
- package/src/machine/activity/sign_in_monthly_activity.js +1 -2
- package/src/machine/activity/specify_bets_activity.js +0 -1
- package/src/machine/activity/specify_turnover_activity.js +0 -1
- package/src/machine/activity/time_bomb_activity.js +0 -1
- package/src/machine/activity/vip_card_activity.js +0 -1
- package/src/machine/auth.js +112 -113
- package/src/machine/auth_otp_v3.js +11 -8
- package/src/machine/bank_binding.js +2 -3
- package/src/machine/common.js +14 -112
- package/src/machine/deposit/crypto_bank_cash.js +20 -35
- package/src/machine/deposit/crypto_qrcode_cash.js +26 -64
- package/src/machine/deposit/crypto_way_cash.js +48 -37
- package/src/machine/deposit/direct_cash.js +8 -10
- package/src/machine/deposit/index.js +0 -28
- package/src/machine/deposit/loadcard_cash.js +14 -32
- package/src/machine/deposit/manual_cash.js +18 -28
- package/src/machine/deposit/qrcode_cash.js +15 -32
- package/src/machine/deposit/usdt_cash.js +1 -15
- package/src/machine/deposit/virtual_bank_cash.js +13 -12
- package/src/machine/error.js +7 -1
- package/src/machine/game_betslip.js +0 -1
- package/src/machine/game_favorite_v2.js +0 -1
- package/src/machine/game_info.js +1 -13
- package/src/machine/game_search_cash.js +2 -13
- package/src/machine/game_v2_1.js +42 -166
- package/src/machine/honor_board_cash.js +8 -11
- package/src/machine/inbox.js +43 -105
- package/src/machine/index.js +0 -32
- package/src/machine/leaderboard.js +8 -12
- package/src/machine/navbar.js +1 -3
- package/src/machine/ranking.js +45 -30
- package/src/machine/reward_cash.js +0 -40
- package/src/machine/roulette_v2.js +14 -11
- package/src/machine/setting.js +0 -1
- package/src/machine/side_cash.js +3 -3
- package/src/machine/user_info.js +0 -1
- package/src/machine/user_photo.js +0 -1
- package/src/machine/user_reset_password.js +0 -14
- package/src/machine/user_sign_up.js +46 -61
- package/src/machine/websocket.js +18 -62
- package/src/machine/withdraw/index.js +0 -6
- package/src/machine/withdraw/withdraw_manual_cash.js +59 -39
- package/src/request/config.js +2 -0
- package/src/request/request.js +49 -60
- package/src/util/amount.js +8 -0
- package/src/util/constant.js +0 -1
- package/src/util/err998SentryExtra.js +26 -0
- package/src/util/index.js +2 -4
- package/src/util/paramStore.js +139 -0
- package/src/util/storage.js +3 -4
- package/BREAKING_CHANGES.md +0 -9
- package/resetGitBranch.sh +0 -101
- package/src/lib/fingerprint_v3_11_12.js +0 -11433
- package/src/machine/activity/activity.js +0 -213
- package/src/machine/activity/diamond_shop_activity_fc.js +0 -197
- package/src/machine/activity/diamond_shop_activity_vn.js +0 -179
- package/src/machine/activity/invite_friends_activity.js +0 -115
- package/src/machine/activity/mini_game_activity.js +0 -69
- package/src/machine/activity/return_bonus_activity.js +0 -155
- package/src/machine/auth_otp_v2.js +0 -178
- package/src/machine/bank_binding_amb.js +0 -146
- package/src/machine/bonus.js +0 -76
- package/src/machine/deposit/amb.js +0 -93
- package/src/machine/deposit/crypto_bank.js +0 -340
- package/src/machine/deposit/crypto_qrcode.js +0 -158
- package/src/machine/deposit/crypto_way.js +0 -253
- package/src/machine/deposit/deposit_fc.js +0 -272
- package/src/machine/deposit/direct.js +0 -311
- package/src/machine/deposit/float.js +0 -375
- package/src/machine/deposit/krway.js +0 -152
- package/src/machine/deposit/loadcard_vn.js +0 -352
- package/src/machine/deposit/manual_vn.js +0 -463
- package/src/machine/deposit/qrcode_v2.js +0 -339
- package/src/machine/deposit/usdt.js +0 -163
- package/src/machine/deposit/virtual_bank_vn.js +0 -270
- package/src/machine/deposit/vpay.js +0 -374
- package/src/machine/game_hot_new.js +0 -91
- package/src/machine/game_replay.js +0 -47
- package/src/machine/game_search_v2.js +0 -402
- package/src/machine/honor_board.js +0 -144
- package/src/machine/merge.js +0 -58
- package/src/machine/payment_data.js +0 -87
- package/src/machine/promotions.js +0 -163
- package/src/machine/reward.js +0 -256
- package/src/machine/reward_fc.js +0 -99
- package/src/machine/side.js +0 -160
- package/src/machine/side_v2.js +0 -223
- package/src/machine/vip_table.js +0 -58
- package/src/machine/welcome.js +0 -111
- package/src/machine/withdraw/withdraw_crypto_cash.js +0 -328
- package/src/machine/withdraw/withdraw_krway.js +0 -223
- package/src/machine/withdraw/withdraw_manual.js +0 -541
- package/src/util/deviceToken.js +0 -60
- package/src/util/math.js +0 -4
- package/test/api.behavior.test.js +0 -69
- package/test/api.contract.test.js +0 -18
- package/test/config.test.js +0 -27
- package/test/deviceToken.test.js +0 -139
- package/test/helpers.coverage.test.js +0 -11
- package/test/helpers.js +0 -91
- package/test/index.exports.test.js +0 -14
- package/test/machine.activity.core.coverage.test.js +0 -337
- package/test/machine.activity.gap.coverage.test.js +0 -252
- package/test/machine.activity.more.coverage.test.js +0 -180
- package/test/machine.activity_plus_and_binding_amb.coverage.test.js +0 -201
- package/test/machine.activity_timer_bonus.coverage.test.js +0 -136
- package/test/machine.activity_welcome.low.coverage.test.js +0 -211
- package/test/machine.amb_rewardfc_websocket.more.coverage.test.js +0 -201
- package/test/machine.auth.coverage.test.js +0 -215
- package/test/machine.bank_binding.test.js +0 -143
- package/test/machine.binding_otp_krway.coverage.test.js +0 -223
- package/test/machine.contract.test.js +0 -50
- package/test/machine.crypto_bank.coverage.test.js +0 -270
- package/test/machine.crypto_way.coverage.test.js +0 -108
- package/test/machine.crypto_way_cash.coverage.test.js +0 -114
- package/test/machine.definition.test.js +0 -137
- package/test/machine.deposit.manual.coverage.test.js +0 -365
- package/test/machine.deposit_fc.coverage.test.js +0 -126
- package/test/machine.direct.coverage.test.js +0 -96
- package/test/machine.direct_cash.coverage.test.js +0 -108
- package/test/machine.error.coverage.test.js +0 -37
- package/test/machine.events.test.js +0 -126
- package/test/machine.favorite_jackpot.coverage.test.js +0 -82
- package/test/machine.float.coverage.test.js +0 -136
- package/test/machine.flow.test.js +0 -226
- package/test/machine.game_hot_new_vip_table.coverage.test.js +0 -105
- package/test/machine.game_search_cash.coverage.test.js +0 -195
- package/test/machine.game_search_v2.test.js +0 -199
- package/test/machine.game_user_profile.coverage.test.js +0 -100
- package/test/machine.honor_board.test.js +0 -148
- package/test/machine.inbox.common.coverage.test.js +0 -304
- package/test/machine.loadcard_cash.coverage.test.js +0 -101
- package/test/machine.loadcard_vn.coverage.test.js +0 -122
- package/test/machine.misc.coverage.test.js +0 -361
- package/test/machine.more2.coverage.test.js +0 -261
- package/test/machine.options.execution.test.js +0 -272
- package/test/machine.priority.coverage.test.js +0 -629
- package/test/machine.qrcode_cash.coverage.test.js +0 -107
- package/test/machine.qrcode_v2.coverage.test.js +0 -121
- package/test/machine.regression.test.js +0 -82
- package/test/machine.roulette_v2.test.js +0 -142
- package/test/machine.side_reward_reset.coverage.test.js +0 -220
- package/test/machine.targeted.coverage.test.js +0 -313
- package/test/machine.usdt.coverage.test.js +0 -95
- package/test/machine.usdt_cash.coverage.test.js +0 -73
- package/test/machine.vip_card_activity.test.js +0 -114
- package/test/machine.virtual_bank_cash.coverage.test.js +0 -105
- package/test/machine.virtual_bank_vn.coverage.test.js +0 -105
- package/test/machine.vpay.coverage.test.js +0 -142
- package/test/machine.withdraw_crypto_cash.coverage.test.js +0 -166
- package/test/machine.withdraw_krway.coverage.test.js +0 -123
- package/test/machine.withdraw_manual.coverage.test.js +0 -185
- package/test/machine.withdraw_manual_cash.coverage.test.js +0 -123
- package/test/request.test.js +0 -325
- package/test/util.storage.errors.test.js +0 -47
- package/test/util.test.js +0 -41
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
import test from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
|
|
4
|
-
import navbarFactory from '../src/machine/navbar.js'
|
|
5
|
-
import paymentDataFactory from '../src/machine/payment_data.js'
|
|
6
|
-
import rankingFactory from '../src/machine/ranking.js'
|
|
7
|
-
import leaderboardFactory from '../src/machine/leaderboard.js'
|
|
8
|
-
import promotionsFactory from '../src/machine/promotions.js'
|
|
9
|
-
|
|
10
|
-
test('navbar actions/guards/services cover game merge and config decode', async () => {
|
|
11
|
-
global.window = {
|
|
12
|
-
atob: (v) => Buffer.from(v, 'base64').toString('binary'),
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const calls = []
|
|
16
|
-
const request = {
|
|
17
|
-
config: { appSecret: 'secret' },
|
|
18
|
-
send: async (req) => {
|
|
19
|
-
calls.push(req)
|
|
20
|
-
if (req.url === 'getNavbarSetting') {
|
|
21
|
-
const payload = {
|
|
22
|
-
settings: [
|
|
23
|
-
{ type: 'GAME', gameCode: 'G1' },
|
|
24
|
-
{ type: 'LINK', path: '/a' },
|
|
25
|
-
],
|
|
26
|
-
}
|
|
27
|
-
const b64 = Buffer.from(JSON.stringify(payload), 'utf8').toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/g, '')
|
|
28
|
-
return { config: `${b64}.x.y` }
|
|
29
|
-
}
|
|
30
|
-
if (req.url === 'game/list/v3/gameInfo') {
|
|
31
|
-
return { data: [{ gameCode: 'G1', gameName: 'Game One' }] }
|
|
32
|
-
}
|
|
33
|
-
return {}
|
|
34
|
-
},
|
|
35
|
-
}
|
|
36
|
-
const machine = navbarFactory(request)
|
|
37
|
-
const actions = machine.options.actions
|
|
38
|
-
const guards = machine.options.guards
|
|
39
|
-
const services = machine.options.services
|
|
40
|
-
|
|
41
|
-
const navbarPatch = actions.setNavbar.assignment(machine.initialState.context, {
|
|
42
|
-
data: { navbarConfig: { settings: [{ type: 'GAME', gameCode: 'G1' }, { type: 'LINK' }] } },
|
|
43
|
-
})
|
|
44
|
-
assert.equal(navbarPatch.navbar.length, 2)
|
|
45
|
-
|
|
46
|
-
const gameCodePatch = actions.filterGameCodes.assignment(
|
|
47
|
-
{ ...machine.initialState.context, navbar: [{ type: 'GAME', gameCode: 'G1' }, { type: 'LINK' }, { type: 'game' }] },
|
|
48
|
-
{}
|
|
49
|
-
)
|
|
50
|
-
assert.deepEqual(gameCodePatch.gameCodes, ['G1'])
|
|
51
|
-
|
|
52
|
-
const combined = actions.combindGames.assignment(
|
|
53
|
-
{
|
|
54
|
-
...machine.initialState.context,
|
|
55
|
-
navbar: [
|
|
56
|
-
{ type: 'game', gameCode: 'G1' },
|
|
57
|
-
{ type: 'link', path: '/a' },
|
|
58
|
-
],
|
|
59
|
-
},
|
|
60
|
-
{ data: { data: [{ gameCode: 'G1', gameName: 'Game One' }] } }
|
|
61
|
-
)
|
|
62
|
-
assert.equal(combined.navbar[0].gameName, 'Game One')
|
|
63
|
-
assert.equal(combined.navbar[1].path, '/a')
|
|
64
|
-
|
|
65
|
-
assert.equal(guards.haveGames({}, { data: { navbarConfig: { settings: [{ type: 'game' }] } } }), true)
|
|
66
|
-
assert.equal(guards.haveGames({}, { data: { navbarConfig: { settings: [] } } }), false)
|
|
67
|
-
|
|
68
|
-
const decoded = await services.fetchNavbar({}, {})
|
|
69
|
-
assert.equal(decoded.navbarConfig.settings[0].gameCode, 'G1')
|
|
70
|
-
const gameInfo = await services.getGameInfo({ gameCodes: ['G1'] }, {})
|
|
71
|
-
assert.equal(gameInfo.data[0].gameName, 'Game One')
|
|
72
|
-
assert.equal(calls.length >= 2, true)
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
test('payment_data actions/services map status and spot market list', async () => {
|
|
76
|
-
const calls = []
|
|
77
|
-
const request = {
|
|
78
|
-
send: async (req) => {
|
|
79
|
-
calls.push(req)
|
|
80
|
-
if (req.url === 'payment/v2/history')
|
|
81
|
-
return [
|
|
82
|
-
{ id: 1, status: 2 },
|
|
83
|
-
{ id: 2, status: 3 },
|
|
84
|
-
{ id: 3, status: 99 },
|
|
85
|
-
]
|
|
86
|
-
if (req.url === 'payment/v2/spotmarket') return { timestamp: 10, data: Array.from({ length: 120 }, (_, i) => ({ i })) }
|
|
87
|
-
return {}
|
|
88
|
-
},
|
|
89
|
-
}
|
|
90
|
-
const machine = paymentDataFactory(request)
|
|
91
|
-
const actions = machine.options.actions
|
|
92
|
-
const services = machine.options.services
|
|
93
|
-
|
|
94
|
-
const mapped = actions.setTransactionList.assignment(machine.initialState.context, {
|
|
95
|
-
data: [{ status: 2 }, { status: 3 }, { status: 4 }, { status: 8 }, { status: 1 }],
|
|
96
|
-
})
|
|
97
|
-
assert.deepEqual(
|
|
98
|
-
mapped.transactionList.map((x) => x.statusName),
|
|
99
|
-
['pending', 'success', 'reject', 'expired', undefined]
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
const spot = actions.setSpotMarket.assignment(machine.initialState.context, {
|
|
103
|
-
data: { timestamp: 99, data: Array.from({ length: 120 }, (_, i) => i) },
|
|
104
|
-
})
|
|
105
|
-
assert.equal(spot.spotMarketTime, 99)
|
|
106
|
-
assert.equal(spot.spotMarketList.length, 100)
|
|
107
|
-
|
|
108
|
-
const list = await services.fetchTransactionList({}, { data: 7 })
|
|
109
|
-
assert.equal(list.length, 3)
|
|
110
|
-
const market = await services.fetchSpotMarket({}, {})
|
|
111
|
-
assert.equal(market.data.length, 120)
|
|
112
|
-
assert.equal(calls.length, 2)
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
test('ranking actions/guards/services cover champion options and detail flows', async () => {
|
|
116
|
-
const calls = []
|
|
117
|
-
const request = {
|
|
118
|
-
config: { appSecret: 'secret' },
|
|
119
|
-
getToken: () => 'token',
|
|
120
|
-
send: async (req) => {
|
|
121
|
-
calls.push(req)
|
|
122
|
-
if (req.url === 'ranking/detail/option') {
|
|
123
|
-
return { data: { rule: 'CHAMPION', cycle: 'MONTHLY', currentRound: [30, 8, 2] } }
|
|
124
|
-
}
|
|
125
|
-
if (req.url === 'hot-game/ranking') return { data: [{ provider: 'PG', gameCode: 'G1' }] }
|
|
126
|
-
if (req.url === 'ranking/detail') {
|
|
127
|
-
return {
|
|
128
|
-
data: { topRanking: [{ provider: 'PG', settleStatus: true }], playerRanking: { provider: 'EV' }, description: 'd', descriptionUrl: ['u'] },
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (req.url === 'tournament/detail') return { data: { topRanking: [], playerRanking: {} } }
|
|
132
|
-
return {}
|
|
133
|
-
},
|
|
134
|
-
}
|
|
135
|
-
const machine = rankingFactory(request)
|
|
136
|
-
const actions = machine.options.actions
|
|
137
|
-
const guards = machine.options.guards
|
|
138
|
-
const services = machine.options.services
|
|
139
|
-
|
|
140
|
-
const setActivity = actions.setActivity.assignment(machine.initialState.context, {
|
|
141
|
-
data: { site: 's1', activityNo: 'A1' },
|
|
142
|
-
})
|
|
143
|
-
assert.equal(setActivity.auth, true)
|
|
144
|
-
|
|
145
|
-
const setRanking = actions.setRanking.assignment(machine.initialState.context, {
|
|
146
|
-
data: { topRanking: [{ provider: 'PG', settleStatus: true }], playerRanking: { provider: 'EV' }, description: 'desc' },
|
|
147
|
-
})
|
|
148
|
-
assert.equal(setRanking.topRanking[0].providerId, 'PG')
|
|
149
|
-
assert.equal(setRanking.playerRanking.providerId, 'EV')
|
|
150
|
-
assert.equal(setRanking.settleStatus, true)
|
|
151
|
-
|
|
152
|
-
const setRankingGames = actions.setRankingGames.assignment(machine.initialState.context, {
|
|
153
|
-
data: [{ provider: 'PG', gameCode: 'G1' }],
|
|
154
|
-
})
|
|
155
|
-
assert.equal(setRankingGames.gameRanking[0].providerId, 'PG')
|
|
156
|
-
|
|
157
|
-
const options = actions.setRankingOptions.assignment(machine.initialState.context, {
|
|
158
|
-
data: { rule: 'CHAMPION', cycle: 'MONTHLY', currentRound: [30, 8, 2] },
|
|
159
|
-
})
|
|
160
|
-
assert.deepEqual(options.options.cycle, ['DAILY', 'WEEKLY', 'MONTHLY', 'ALL'])
|
|
161
|
-
assert.equal(options.cycle, 'DAILY')
|
|
162
|
-
assert.equal(options.round, 30)
|
|
163
|
-
assert.equal(options.options.round.DAILY.length, 30)
|
|
164
|
-
assert.equal(options.options.round.ALL.length, 2)
|
|
165
|
-
const nonChampionOptions = actions.setRankingOptions.assignment(machine.initialState.context, {
|
|
166
|
-
data: { rule: 'NORMAL', cycle: 'WEEKLY', currentRound: [10] },
|
|
167
|
-
})
|
|
168
|
-
assert.deepEqual(nonChampionOptions.options.cycle, ['WEEKLY'])
|
|
169
|
-
assert.equal(nonChampionOptions.cycle, 'WEEKLY')
|
|
170
|
-
const rankingNoData = actions.setRanking.assignment(machine.initialState.context, { data: null })
|
|
171
|
-
assert.deepEqual(rankingNoData.topRanking, [])
|
|
172
|
-
assert.deepEqual(rankingNoData.playerRanking, {})
|
|
173
|
-
assert.deepEqual(actions.setRankingGames.assignment(machine.initialState.context, { data: null }).gameRanking, [])
|
|
174
|
-
|
|
175
|
-
const setCycle = actions.setOptions.assignment(
|
|
176
|
-
{ ...machine.initialState.context, currentRound: [30, 8, 2], cycle: 'DAILY', round: 30 },
|
|
177
|
-
{ data: { cycle: 'WEEKLY' } }
|
|
178
|
-
)
|
|
179
|
-
assert.equal(setCycle.cycle, 'WEEKLY')
|
|
180
|
-
assert.equal(setCycle.round, 8)
|
|
181
|
-
|
|
182
|
-
const setRound = actions.setOptions.assignment({ ...machine.initialState.context, cycle: 'WEEKLY', round: 8 }, { data: { round: 7 } })
|
|
183
|
-
assert.equal(setRound.round, 7)
|
|
184
|
-
const setAllCycle = actions.setOptions.assignment(
|
|
185
|
-
{ ...machine.initialState.context, currentRound: [30, 8, 2], cycle: 'DAILY', round: 30 },
|
|
186
|
-
{ data: { cycle: 'ALL' } }
|
|
187
|
-
)
|
|
188
|
-
assert.equal(setAllCycle.round, 2)
|
|
189
|
-
assert.deepEqual(actions.setOptions.assignment({ ...machine.initialState.context, cycle: 'WEEKLY', round: 7 }, { data: { round: 7 } }), {})
|
|
190
|
-
|
|
191
|
-
assert.equal(guards.hasAuth({ auth: true }), true)
|
|
192
|
-
assert.equal(guards.canGetGameRanking({ auth: true, rule: 'CHAMPION' }), true)
|
|
193
|
-
assert.equal(guards.canGetGameRanking({ auth: true, rule: 'OTHER' }), false)
|
|
194
|
-
|
|
195
|
-
const optRes = await services.fetchRankingOptions({ activityNo: 'A1' })
|
|
196
|
-
const gamesRes = await services.fetchRankingGames({ activityNo: 'A1' })
|
|
197
|
-
const detailRes = await services.fetchRankingDetail({ activityNo: 'A1', cycle: 'DAILY', round: 1 })
|
|
198
|
-
const tourRes = await services.fetchTournament({ activityNo: 'A1', cycle: 'DAILY', round: 1, site: 's1' })
|
|
199
|
-
assert.equal(optRes.rule, 'CHAMPION')
|
|
200
|
-
assert.equal(gamesRes[0].provider, 'PG')
|
|
201
|
-
assert.equal(detailRes.description, 'd')
|
|
202
|
-
assert.deepEqual(tourRes.topRanking, [])
|
|
203
|
-
assert.equal(calls.length >= 4, true)
|
|
204
|
-
})
|
|
205
|
-
|
|
206
|
-
test('leaderboard actions/guards/services cover map cache and auth branches', async () => {
|
|
207
|
-
const calls = []
|
|
208
|
-
let hasToken = false
|
|
209
|
-
const request = {
|
|
210
|
-
config: { appSecret: 'secret' },
|
|
211
|
-
getToken: () => (hasToken ? 'token' : null),
|
|
212
|
-
send: async (req) => {
|
|
213
|
-
calls.push(req)
|
|
214
|
-
if (req.url === 'all-activities/list' || req.url === 'activities/list') {
|
|
215
|
-
return { data: [{ activityType: 2 }, { activityType: 200 }, { activityType: 1 }] }
|
|
216
|
-
}
|
|
217
|
-
if (req.url === 'tournament/detail') {
|
|
218
|
-
return { data: { topRanking: [{ rank: 1 }], awards: ['A'] } }
|
|
219
|
-
}
|
|
220
|
-
if (req.url === 'activities') {
|
|
221
|
-
return { data: { rankingList: [{ rank: 2 }], awards: ['B'] } }
|
|
222
|
-
}
|
|
223
|
-
return { data: {} }
|
|
224
|
-
},
|
|
225
|
-
}
|
|
226
|
-
const machine = leaderboardFactory(request)
|
|
227
|
-
const actions = machine.options.actions
|
|
228
|
-
const guards = machine.options.guards
|
|
229
|
-
const services = machine.options.services
|
|
230
|
-
|
|
231
|
-
const rankActivities = actions.setRankActivities.assignment(machine.initialState.context, {
|
|
232
|
-
data: [{ activityType: 2 }, { activityType: 200 }, { activityType: 99 }],
|
|
233
|
-
})
|
|
234
|
-
assert.equal(rankActivities.rankActivities.length, 2)
|
|
235
|
-
|
|
236
|
-
assert.equal(actions.setActivityNo.assignment(machine.initialState.context, { data: 'A1' }).activityNo, 'A1')
|
|
237
|
-
|
|
238
|
-
const withRankingList = actions.setActivityMap.assignment(
|
|
239
|
-
{ ...machine.initialState.context, activityNo: 'A1', activityMap: {} },
|
|
240
|
-
{ data: { rankingList: [{ id: 1 }], awards: ['A'] } }
|
|
241
|
-
)
|
|
242
|
-
assert.equal(withRankingList.activityMap.A1.topRanking.length, 1)
|
|
243
|
-
|
|
244
|
-
const withoutRankingList = actions.setActivityMap.assignment(
|
|
245
|
-
{ ...machine.initialState.context, activityNo: 'A2', activityMap: {} },
|
|
246
|
-
{ data: { any: 1, awards: ['B'] } }
|
|
247
|
-
)
|
|
248
|
-
assert.equal(withoutRankingList.activityMap.A2.any, 1)
|
|
249
|
-
|
|
250
|
-
const detail = actions.setActivityDetail.assignment(
|
|
251
|
-
{ ...machine.initialState.context, activityNo: 'A1', activityMap: { A1: { topRanking: [] } } },
|
|
252
|
-
{}
|
|
253
|
-
)
|
|
254
|
-
assert.deepEqual(detail.activityDetail, { topRanking: [] })
|
|
255
|
-
|
|
256
|
-
assert.equal(Boolean(guards.isExist({ activityMap: { A1: {} }, activityNo: 'A1' })), true)
|
|
257
|
-
assert.equal(guards.hasActivityNo({ activityNo: 'A1' }), true)
|
|
258
|
-
|
|
259
|
-
const originalSetTimeout = global.setTimeout
|
|
260
|
-
global.setTimeout = (fn) => {
|
|
261
|
-
fn()
|
|
262
|
-
return 0
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
hasToken = false
|
|
266
|
-
const listPublic = await services.fetchActivityList({}, {})
|
|
267
|
-
hasToken = true
|
|
268
|
-
const listAuthed = await services.fetchActivityList({}, {})
|
|
269
|
-
hasToken = false
|
|
270
|
-
const detailPublic = await services.fetchPublicActivityDetail({ activityNo: 'A1' }, {})
|
|
271
|
-
hasToken = true
|
|
272
|
-
const detailAuthed = await services.fetchPublicActivityDetail({ activityNo: 'A1' }, {})
|
|
273
|
-
global.setTimeout = originalSetTimeout
|
|
274
|
-
|
|
275
|
-
assert.equal(listPublic.length, 3)
|
|
276
|
-
assert.equal(listAuthed.length, 3)
|
|
277
|
-
assert.deepEqual(detailPublic.topRanking, [{ rank: 1 }])
|
|
278
|
-
assert.deepEqual(detailAuthed.rankingList, [{ rank: 2 }])
|
|
279
|
-
assert.equal(calls.length >= 4, true)
|
|
280
|
-
})
|
|
281
|
-
|
|
282
|
-
test('promotions actions/guards/services cover attendEnable and callback flow', async () => {
|
|
283
|
-
const calls = []
|
|
284
|
-
const request = {
|
|
285
|
-
send: async (req) => {
|
|
286
|
-
calls.push(req)
|
|
287
|
-
if (req.url === 'payment/v2/bankWallet/promotions') {
|
|
288
|
-
return [
|
|
289
|
-
{ promotionsNo: 'P1', withdrawRule: 'FREE_LIMIT', minimumAmount: 100 },
|
|
290
|
-
{ promotionsNo: 'P2', withdrawRule: 'DEFAULT', minimumAmount: 200 },
|
|
291
|
-
]
|
|
292
|
-
}
|
|
293
|
-
if (req.url === 'payment/v2/bankWallet/promotion/preview') return { preview: true }
|
|
294
|
-
if (req.url === 'payment/v2/bankWallet/promotion/apply') return { ok: true }
|
|
295
|
-
return {}
|
|
296
|
-
},
|
|
297
|
-
}
|
|
298
|
-
const machine = promotionsFactory(request)
|
|
299
|
-
const actions = machine.options.actions
|
|
300
|
-
const guards = machine.options.guards
|
|
301
|
-
const services = machine.options.services
|
|
302
|
-
|
|
303
|
-
const defaultRule = actions.setPromotionsList.assignment(
|
|
304
|
-
{
|
|
305
|
-
...machine.initialState.context,
|
|
306
|
-
userInfo: { withdraw_rule: 'DEFAULT', bank_amount: '1000' },
|
|
307
|
-
siteConfig: { currencyConversionLimit: 500 },
|
|
308
|
-
},
|
|
309
|
-
{ data: [{ withdrawRule: 'FREE_LIMIT' }, { withdrawRule: 'DEFAULT' }] }
|
|
310
|
-
)
|
|
311
|
-
assert.equal(defaultRule.promotionsList[0].attendEnable, false)
|
|
312
|
-
assert.equal(defaultRule.promotionsList[1].attendEnable, true)
|
|
313
|
-
|
|
314
|
-
const freeLimitRule = actions.setPromotionsList.assignment(
|
|
315
|
-
{
|
|
316
|
-
...machine.initialState.context,
|
|
317
|
-
userInfo: { withdraw_rule: 'FREE_LIMIT', bank_amount: '1000' },
|
|
318
|
-
siteConfig: { currencyConversionLimit: 500 },
|
|
319
|
-
},
|
|
320
|
-
{ data: [{ withdrawRule: 'FREE_LIMIT' }, { withdrawRule: 'DEFAULT' }] }
|
|
321
|
-
)
|
|
322
|
-
assert.equal(
|
|
323
|
-
freeLimitRule.promotionsList.every((x) => x.attendEnable === false),
|
|
324
|
-
true
|
|
325
|
-
)
|
|
326
|
-
|
|
327
|
-
const freeCase = actions.setPromotionsList.assignment(
|
|
328
|
-
{
|
|
329
|
-
...machine.initialState.context,
|
|
330
|
-
userInfo: { withdraw_rule: 'DEFAULT', bank_amount: '100' },
|
|
331
|
-
siteConfig: { currencyConversionLimit: 500 },
|
|
332
|
-
},
|
|
333
|
-
{ data: [{ withdrawRule: 'FREE_LIMIT' }, { withdrawRule: 'DEFAULT' }] }
|
|
334
|
-
)
|
|
335
|
-
assert.equal(
|
|
336
|
-
freeCase.promotionsList.every((x) => x.attendEnable === true),
|
|
337
|
-
true
|
|
338
|
-
)
|
|
339
|
-
|
|
340
|
-
assert.equal(actions.setSelectedPromo.assignment(machine.initialState.context, { data: { promotionsNo: 'P1' } }).selectedPromo.promotionsNo, 'P1')
|
|
341
|
-
assert.equal(actions.setAmount.assignment(machine.initialState.context, { data: 123 }).amount, 123)
|
|
342
|
-
assert.deepEqual(actions.setWithdrawRulePreview.assignment(machine.initialState.context, { data: { x: 1 } }).withdrawRule, { x: 1 })
|
|
343
|
-
|
|
344
|
-
let called = 0
|
|
345
|
-
const callbackPatch = actions.setCallback.assignment(machine.initialState.context, { data: { callback: () => called++ } })
|
|
346
|
-
assert.equal(typeof callbackPatch.callback, 'function')
|
|
347
|
-
actions.doCallback({ callback: callbackPatch.callback }, {})
|
|
348
|
-
assert.equal(called, 1)
|
|
349
|
-
assert.equal(actions.reset.assignment(machine.initialState.context, {}).amount, null)
|
|
350
|
-
|
|
351
|
-
assert.equal(guards.isValidAmount({ selectedPromo: { minimumAmount: 100 }, amount: 100 }), true)
|
|
352
|
-
assert.equal(guards.isValidAmount({ selectedPromo: { minimumAmount: 100 }, amount: 99 }), false)
|
|
353
|
-
|
|
354
|
-
const promoList = await services.fetchPromotionsList({}, {})
|
|
355
|
-
const preview = await services.fetchWithdrawRulePreview({ selectedPromo: { promotionsNo: 'P1' }, amount: '123.45' }, {})
|
|
356
|
-
const apply = await services.applyPromotion({ selectedPromo: { promotionsNo: 'P2' }, amount: '99.5' }, {})
|
|
357
|
-
assert.equal(Array.isArray(promoList), true)
|
|
358
|
-
assert.equal(preview.preview, true)
|
|
359
|
-
assert.equal(apply.ok, true)
|
|
360
|
-
assert.equal(calls.length, 3)
|
|
361
|
-
})
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import test from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
|
|
4
|
-
import sideCashFactory from '../src/machine/side_cash.js'
|
|
5
|
-
import authOtpV3Factory from '../src/machine/auth_otp_v3.js'
|
|
6
|
-
import cryptoQrcodeFactory from '../src/machine/deposit/crypto_qrcode.js'
|
|
7
|
-
import cryptoQrcodeCashFactory from '../src/machine/deposit/crypto_qrcode_cash.js'
|
|
8
|
-
|
|
9
|
-
test('side_cash actions/services cover menu build and update branches', async () => {
|
|
10
|
-
const calls = []
|
|
11
|
-
const request = {
|
|
12
|
-
config: { appSecret: 'secret' },
|
|
13
|
-
send: async (req) => {
|
|
14
|
-
calls.push(req)
|
|
15
|
-
return {
|
|
16
|
-
timestamp: 99,
|
|
17
|
-
data: [{ categoryId: 1, isGame: false, sub: [{ categoryId: 11, isGame: false, sub: [{ categoryId: 111, isGame: true, sub: [] }] }] }],
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
}
|
|
21
|
-
const machine = sideCashFactory(request)
|
|
22
|
-
const actions = machine.options.actions
|
|
23
|
-
const services = machine.options.services
|
|
24
|
-
|
|
25
|
-
const setMenu = actions.setMenu.assignment(machine.initialState.context, {
|
|
26
|
-
data: {
|
|
27
|
-
timestamp: 1,
|
|
28
|
-
data: [{ categoryId: 1, isGame: false, sub: [{ categoryId: 2, isGame: true, sub: [] }] }],
|
|
29
|
-
},
|
|
30
|
-
})
|
|
31
|
-
assert.equal(setMenu.menu.data[0].level, 0)
|
|
32
|
-
assert.equal(setMenu.menu.data[0].sub[0].level, 1)
|
|
33
|
-
|
|
34
|
-
const updated = actions.updateMenu.assignment(machine.initialState.context, {
|
|
35
|
-
data: {
|
|
36
|
-
timestamp: 2,
|
|
37
|
-
data: [{ categoryId: 1, isGame: false, sub: [{ categoryId: 2, isGame: false, sub: [{ categoryId: 3, isGame: true, sub: [] }] }] }],
|
|
38
|
-
},
|
|
39
|
-
})
|
|
40
|
-
assert.equal(updated.menu.data[0].level, 0)
|
|
41
|
-
assert.equal(updated.defaultMenuItemStack.length, 3)
|
|
42
|
-
assert.equal(actions.updateMenu.assignment(machine.initialState.context, { data: { data: [] } }), undefined)
|
|
43
|
-
|
|
44
|
-
const menu = await services.getMenu({}, {})
|
|
45
|
-
const patch = await services.fetchUpdateMenu({ menu: { timestamp: 88 } }, {})
|
|
46
|
-
assert.equal(menu.data[0].categoryId, 1)
|
|
47
|
-
assert.equal(patch.timestamp, 99)
|
|
48
|
-
assert.equal(calls.length, 2)
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
test('auth_otp_v3 actions/guards/services cover verification flow branches', async () => {
|
|
52
|
-
const calls = []
|
|
53
|
-
const request = {
|
|
54
|
-
send: async (req) => {
|
|
55
|
-
calls.push(req)
|
|
56
|
-
if (req.url === 'self') return { verification_status: 0, phone: null, email: null }
|
|
57
|
-
if (req.url === 'otp-verification-point/verify') return { request_id: 'R1', ttl: 3000, email: 'a@b.c', countryCode: '66', phone: '0800' }
|
|
58
|
-
if (req.url === 'otp-verification-point/reset-otp') return { request_id: 'R2', ttl: 2000, email: 'a@b.c' }
|
|
59
|
-
if (req.url === 'otp-verification-point/acknowledge') return { ok: true }
|
|
60
|
-
return {}
|
|
61
|
-
},
|
|
62
|
-
}
|
|
63
|
-
const machine = authOtpV3Factory(request)
|
|
64
|
-
const actions = machine.options.actions
|
|
65
|
-
const guards = machine.options.guards
|
|
66
|
-
const services = machine.options.services
|
|
67
|
-
|
|
68
|
-
assert.equal(actions.setStrategy.assignment(machine.initialState.context, { data: 'phone' }).strategy, 'phone')
|
|
69
|
-
assert.equal(actions.setUserInfo.assignment(machine.initialState.context, { data: { id: 1 } }).userInfo.id, 1)
|
|
70
|
-
|
|
71
|
-
const verifyData = actions.setVerificationData.assignment(
|
|
72
|
-
{ ...machine.initialState.context, strategy: 'phone' },
|
|
73
|
-
{ data: { request_id: 'R1', ttl: 3000, email: 'a@b.c', countryCode: '66', phone: '0800' } }
|
|
74
|
-
)
|
|
75
|
-
assert.equal(verifyData.requestId, 'R1')
|
|
76
|
-
assert.equal(verifyData.ttl, 3000)
|
|
77
|
-
assert.equal(verifyData.target.provider, 'phone')
|
|
78
|
-
|
|
79
|
-
assert.equal(actions.decreaseTtl.assignment({ ttl: 3000 }, {}).ttl, 2000)
|
|
80
|
-
assert.equal(actions.decreaseTtl.assignment({ ttl: 500 }, {}).ttl, 0)
|
|
81
|
-
assert.equal(actions.setError.assignment(machine.initialState.context, { data: { code: 'ERR' } }).error.code, 'ERR')
|
|
82
|
-
assert.equal(actions.setPhone.assignment(machine.initialState.context, { data: { countryCode: '66', phone: '0800' } }).countryCode, '66')
|
|
83
|
-
assert.equal(actions.setEmail.assignment(machine.initialState.context, { data: { email: 'x@y.z' } }).email, 'x@y.z')
|
|
84
|
-
|
|
85
|
-
assert.equal(guards.isVerified({ userInfo: { verification_status: 1 } }), true)
|
|
86
|
-
assert.equal(guards.isNotVerified({ userInfo: { verification_status: 2 } }), true)
|
|
87
|
-
assert.equal(guards.isPhoneNotVerified({ strategy: 'phone', userInfo: { verification_status: 0, phone: null } }), true)
|
|
88
|
-
assert.equal(guards.isEmailNotVerified({ strategy: 'email', userInfo: { verification_status: 0, email: null } }), true)
|
|
89
|
-
assert.equal(guards.hasNoPhone({ error: { code: 'ERR_F106' } }), true)
|
|
90
|
-
assert.equal(guards.isAutoVerified({ status: 'success-verified' }), true)
|
|
91
|
-
|
|
92
|
-
const userInfo = await services.fetchUserInfo({}, {})
|
|
93
|
-
const verifySkip = await services.verify({ strategy: null }, { data: {} })
|
|
94
|
-
const verifyPhone = await services.verify({ strategy: 'phone' }, { data: { country_code: '66', tel: '0800' } })
|
|
95
|
-
const verifyEmail = await services.verify({ strategy: 'email' }, { data: { email: 'a@b.c' } })
|
|
96
|
-
const sendPhone = await services.sendPhone({ countryCode: '66', phone: '0800' }, {})
|
|
97
|
-
const sendEmail = await services.sendEmail({ email: 'a@b.c' }, {})
|
|
98
|
-
const resetOtp = await services.resetOtp({ requestId: 'R1', target: {} }, {})
|
|
99
|
-
const ack = await services.acknowledge({ requestId: 'R1', target: {} }, { data: '123456' })
|
|
100
|
-
|
|
101
|
-
assert.equal(userInfo.verification_status, 0)
|
|
102
|
-
assert.equal(verifySkip, undefined)
|
|
103
|
-
assert.equal(verifyPhone.request_id, 'R1')
|
|
104
|
-
assert.equal(verifyEmail.request_id, 'R1')
|
|
105
|
-
assert.equal(sendPhone.request_id, 'R1')
|
|
106
|
-
assert.equal(sendEmail.request_id, 'R1')
|
|
107
|
-
assert.equal(resetOtp.request_id, 'R2')
|
|
108
|
-
assert.equal(ack.ok, true)
|
|
109
|
-
assert.equal(calls.length >= 7, true)
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
test('crypto_qrcode actions/guards/services cover selection and local-cache branches', async () => {
|
|
113
|
-
const calls = []
|
|
114
|
-
const request = {
|
|
115
|
-
send: async (req) => {
|
|
116
|
-
calls.push(req)
|
|
117
|
-
if (req.url === 'payment/v2/paymentDetail') {
|
|
118
|
-
return [
|
|
119
|
-
{
|
|
120
|
-
transferType: 'deposit',
|
|
121
|
-
category: 'cryptoQrcode',
|
|
122
|
-
cryptoOptional: ['USDT'],
|
|
123
|
-
networkName: ['TRC20'],
|
|
124
|
-
channel: 'USDT',
|
|
125
|
-
method: 'crypto_qrcode',
|
|
126
|
-
},
|
|
127
|
-
]
|
|
128
|
-
}
|
|
129
|
-
if (req.url === 'payment/v2/crypto_qrcode/transaction') {
|
|
130
|
-
return {
|
|
131
|
-
action: 'pay',
|
|
132
|
-
cdtime: 60,
|
|
133
|
-
accountNumber: 'addr',
|
|
134
|
-
currency: 'USDT',
|
|
135
|
-
network: 'TRC20',
|
|
136
|
-
name: 'x',
|
|
137
|
-
qrcode: 'q',
|
|
138
|
-
redirect: 'r',
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return {}
|
|
142
|
-
},
|
|
143
|
-
}
|
|
144
|
-
const machine = cryptoQrcodeFactory(request)
|
|
145
|
-
const actions = machine.options.actions
|
|
146
|
-
const guards = machine.options.guards
|
|
147
|
-
const services = machine.options.services
|
|
148
|
-
|
|
149
|
-
const init = actions.setInitData.assignment(machine.initialState.context, {
|
|
150
|
-
data: [
|
|
151
|
-
{
|
|
152
|
-
transferType: 'deposit',
|
|
153
|
-
category: 'cryptoQrcode',
|
|
154
|
-
cryptoOptional: ['USDT'],
|
|
155
|
-
networkName: ['TRC20'],
|
|
156
|
-
channel: 'USDT',
|
|
157
|
-
method: 'crypto_qrcode',
|
|
158
|
-
},
|
|
159
|
-
],
|
|
160
|
-
})
|
|
161
|
-
assert.equal(init.cryptos.length, 1)
|
|
162
|
-
assert.equal(init.selectedCrypto.network, 'TRC20')
|
|
163
|
-
assert.equal(init.currentPayment.method, 'crypto_qrcode')
|
|
164
|
-
|
|
165
|
-
assert.deepEqual(actions.setCrypto.assignment({ cryptos: init.cryptos }, { data: { label: 'UNKNOWN' } }), {})
|
|
166
|
-
const setCrypto = actions.setCrypto.assignment({ cryptos: init.cryptos }, { data: { label: 'USDT' } })
|
|
167
|
-
assert.equal(setCrypto.selectedCrypto.label, 'USDT')
|
|
168
|
-
|
|
169
|
-
assert.deepEqual(actions.setResultFromLocal.assignment({ resultMap: {}, selectedCrypto: null }, {}), {})
|
|
170
|
-
assert.deepEqual(actions.setResultFromLocal.assignment({ resultMap: { TRC20: { a: 1 } }, selectedCrypto: { network: 'TRC20' } }, {}).result, {
|
|
171
|
-
a: 1,
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
const result = actions.setResult.assignment(
|
|
175
|
-
{ resultMap: {}, selectedCrypto: { network: 'TRC20' } },
|
|
176
|
-
{ data: { action: 'pay', cdtime: 10, accountNumber: 'addr', currency: 'USDT', network: 'TRC20', name: 'n', qrcode: 'q', redirect: 'r' } }
|
|
177
|
-
)
|
|
178
|
-
assert.equal(result.resultMap.TRC20.action, 'pay')
|
|
179
|
-
assert.equal(guards.isFound({ resultMap: {}, selectedCrypto: null }), false)
|
|
180
|
-
assert.deepEqual(guards.isFound({ resultMap: { TRC20: { ok: 1 } }, selectedCrypto: { network: 'TRC20' } }), { ok: 1 })
|
|
181
|
-
|
|
182
|
-
const detail = await services.fetchPaymentDetail({}, {})
|
|
183
|
-
const submit = await services.submitDeposit(
|
|
184
|
-
{ currentPayment: { method: 'crypto_qrcode', channel: 'USDT' }, selectedCrypto: { network: 'TRC20' } },
|
|
185
|
-
{}
|
|
186
|
-
)
|
|
187
|
-
assert.equal(Array.isArray(detail), true)
|
|
188
|
-
assert.equal(submit.currency, 'USDT')
|
|
189
|
-
assert.equal(calls.length, 2)
|
|
190
|
-
})
|
|
191
|
-
|
|
192
|
-
test('crypto_qrcode_cash actions/guards/services cover network key branches', async () => {
|
|
193
|
-
const calls = []
|
|
194
|
-
const request = {
|
|
195
|
-
send: async (req) => {
|
|
196
|
-
calls.push(req)
|
|
197
|
-
if (req.url === 'payment/v2/paymentDetail') {
|
|
198
|
-
return [
|
|
199
|
-
{
|
|
200
|
-
category: 'cryptoQrcode',
|
|
201
|
-
cryptoOptional: ['USDT'],
|
|
202
|
-
networkName: ['TRC20'],
|
|
203
|
-
channel: 'USDT',
|
|
204
|
-
method: 'crypto_qrcode_cash',
|
|
205
|
-
},
|
|
206
|
-
]
|
|
207
|
-
}
|
|
208
|
-
if (req.url === 'payment/v2/crypto_qrcode_cash/transaction') {
|
|
209
|
-
return {
|
|
210
|
-
accountNumber: 'addr',
|
|
211
|
-
action: 'pay',
|
|
212
|
-
currency: 'USDT',
|
|
213
|
-
network: 'TRC20',
|
|
214
|
-
qrcode: 'q',
|
|
215
|
-
forexRate: '1',
|
|
216
|
-
redirect: 'r',
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
return {}
|
|
220
|
-
},
|
|
221
|
-
}
|
|
222
|
-
const machine = cryptoQrcodeCashFactory(request)
|
|
223
|
-
const actions = machine.options.actions
|
|
224
|
-
const guards = machine.options.guards
|
|
225
|
-
const services = machine.options.services
|
|
226
|
-
|
|
227
|
-
const init = actions.setInitData.assignment(machine.initialState.context, {
|
|
228
|
-
data: [{ category: 'cryptoQrcode', cryptoOptional: ['USDT'], networkName: ['TRC20'], channel: 'USDT', method: 'crypto_qrcode_cash' }],
|
|
229
|
-
})
|
|
230
|
-
assert.equal(init.cryptos.length, 1)
|
|
231
|
-
assert.equal(init.selectedCrypto.label, 'USDT')
|
|
232
|
-
|
|
233
|
-
assert.deepEqual(actions.setCrypto.assignment({ cryptos: init.cryptos }, { data: { label: 'X' } }), {})
|
|
234
|
-
assert.equal(actions.setCrypto.assignment({ cryptos: init.cryptos }, { data: { label: 'USDT' } }).selectedCrypto.label, 'USDT')
|
|
235
|
-
|
|
236
|
-
assert.deepEqual(actions.setNetwork.assignment({ selectedCrypto: null }, { data: { value: 'ERC20' } }), {})
|
|
237
|
-
assert.equal(actions.setNetwork.assignment({ selectedCrypto: init.selectedCrypto }, { data: { value: 'ERC20' } }).selectedCrypto.network, 'ERC20')
|
|
238
|
-
assert.equal(actions.setNetwork.assignment({ selectedCrypto: init.selectedCrypto }, { data: 'TRC20' }).selectedCrypto.network, 'TRC20')
|
|
239
|
-
|
|
240
|
-
assert.deepEqual(actions.setResultFromLocal.assignment({ resultMap: {}, selectedCrypto: null }, {}), {})
|
|
241
|
-
assert.deepEqual(
|
|
242
|
-
actions.setResultFromLocal.assignment({ resultMap: { USDT_TRC20: { hit: 1 } }, selectedCrypto: { channel: 'USDT', network: 'TRC20' } }, {})
|
|
243
|
-
.result,
|
|
244
|
-
{ hit: 1 }
|
|
245
|
-
)
|
|
246
|
-
|
|
247
|
-
const result = actions.setResult.assignment(
|
|
248
|
-
{ resultMap: {}, selectedCrypto: { channel: 'USDT', network: 'TRC20' } },
|
|
249
|
-
{ data: { accountNumber: 'a', action: 'pay', currency: 'USDT', network: 'TRC20', qrcode: 'q', forexRate: '1', redirect: 'r' } }
|
|
250
|
-
)
|
|
251
|
-
assert.equal(result.resultMap.USDT_TRC20.currency, 'USDT')
|
|
252
|
-
|
|
253
|
-
assert.equal(guards.isFound({ resultMap: {}, selectedCrypto: null }), false)
|
|
254
|
-
assert.deepEqual(guards.isFound({ resultMap: { USDT_TRC20: { ok: 1 } }, selectedCrypto: { channel: 'USDT', network: 'TRC20' } }), { ok: 1 })
|
|
255
|
-
|
|
256
|
-
const details = await services.fetchPaymentDetail({}, {})
|
|
257
|
-
const submit = await services.submitDeposit({ selectedCrypto: { method: 'crypto_qrcode_cash', channel: 'USDT', network: 'TRC20' } }, {})
|
|
258
|
-
assert.equal(Array.isArray(details), true)
|
|
259
|
-
assert.equal(submit.currency, 'USDT')
|
|
260
|
-
assert.equal(calls.length, 2)
|
|
261
|
-
})
|