mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-06 01:17:46 +08:00
feat(admin): batch adjust user wallet balances
This commit is contained in:
@@ -17,7 +17,7 @@ vi.mock('@/utils/cache', () => ({
|
||||
cachedRequest: cachedRequestMock,
|
||||
}))
|
||||
|
||||
import { usersApi } from '@/api/users'
|
||||
import { buildUserBatchBalanceAdjustmentPayload, usersApi } from '@/api/users'
|
||||
|
||||
describe('usersApi admin list query', () => {
|
||||
beforeEach(() => {
|
||||
@@ -104,3 +104,25 @@ describe('usersApi admin list query', () => {
|
||||
expect(getMock).toHaveBeenCalledWith('/api/admin/users/target-user/api-keys')
|
||||
})
|
||||
})
|
||||
|
||||
describe('user batch wallet balance payload', () => {
|
||||
it('builds an addition payload from a valid positive amount', () => {
|
||||
expect(buildUserBatchBalanceAdjustmentPayload('add', '12.5')).toEqual({
|
||||
operation: 'add',
|
||||
amount: 12.5,
|
||||
})
|
||||
})
|
||||
|
||||
it('builds a deduction payload from a valid positive amount', () => {
|
||||
expect(buildUserBatchBalanceAdjustmentPayload('deduct', 4)).toEqual({
|
||||
operation: 'deduct',
|
||||
amount: 4,
|
||||
})
|
||||
})
|
||||
|
||||
it('rejects zero, blank, and non-finite amounts', () => {
|
||||
expect(buildUserBatchBalanceAdjustmentPayload('add', '0')).toBeNull()
|
||||
expect(buildUserBatchBalanceAdjustmentPayload('deduct', '')).toBeNull()
|
||||
expect(buildUserBatchBalanceAdjustmentPayload('deduct', '1e999')).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user