77 lines
1.7 KiB
TypeScript
77 lines
1.7 KiB
TypeScript
import assert from 'node:assert/strict'
|
|
import test from 'node:test'
|
|
|
|
import { shouldBlockAcceptanceForMissingShares } from '../src/utils/worker-order-acceptance.ts'
|
|
|
|
test('拼单缺份额:整单指派给当前打手时放行', () => {
|
|
assert.equal(
|
|
shouldBlockAcceptanceForMissingShares({
|
|
shareCount: 0,
|
|
sharingEnabled: true,
|
|
assignedWorkerId: 1013,
|
|
currentWorkerId: 1013,
|
|
}),
|
|
false,
|
|
)
|
|
})
|
|
|
|
test('拼单缺份额:指派给其他打手时拦截', () => {
|
|
assert.equal(
|
|
shouldBlockAcceptanceForMissingShares({
|
|
shareCount: 0,
|
|
sharingEnabled: true,
|
|
assignedWorkerId: 999,
|
|
currentWorkerId: 1013,
|
|
}),
|
|
true,
|
|
)
|
|
})
|
|
|
|
test('拼单缺份额:没有接单人时拦截', () => {
|
|
assert.equal(
|
|
shouldBlockAcceptanceForMissingShares({
|
|
shareCount: 0,
|
|
sharingEnabled: true,
|
|
assignedWorkerId: null,
|
|
currentWorkerId: 1013,
|
|
}),
|
|
true,
|
|
)
|
|
})
|
|
|
|
test('有份额时按正常份额流程处理,不拦截', () => {
|
|
assert.equal(
|
|
shouldBlockAcceptanceForMissingShares({
|
|
shareCount: 1,
|
|
sharingEnabled: true,
|
|
assignedWorkerId: 1013,
|
|
currentWorkerId: 1013,
|
|
}),
|
|
false,
|
|
)
|
|
})
|
|
|
|
test('非拼单整单没有份额,不拦截', () => {
|
|
assert.equal(
|
|
shouldBlockAcceptanceForMissingShares({
|
|
shareCount: 0,
|
|
sharingEnabled: false,
|
|
assignedWorkerId: 1013,
|
|
currentWorkerId: 1013,
|
|
}),
|
|
false,
|
|
)
|
|
})
|
|
|
|
test('本地取不到当前打手 ID 时保持旧行为(拦截)', () => {
|
|
assert.equal(
|
|
shouldBlockAcceptanceForMissingShares({
|
|
shareCount: 0,
|
|
sharingEnabled: true,
|
|
assignedWorkerId: 1013,
|
|
currentWorkerId: 0,
|
|
}),
|
|
true,
|
|
)
|
|
})
|