ывав
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { orderRequiresPriceApproval } from '../order-requires-price-approval'
|
||||
|
||||
describe('orderRequiresPriceApproval', () => {
|
||||
it('returns true when pending payment delivery fee is not locked for delivery', () => {
|
||||
const result = orderRequiresPriceApproval({
|
||||
status: 'PENDING_PAYMENT',
|
||||
deliveryType: 'delivery',
|
||||
deliveryFeeLocked: false,
|
||||
})
|
||||
|
||||
expect(result).toBe(true)
|
||||
})
|
||||
|
||||
it('returns false when status is not pending payment', () => {
|
||||
const result = orderRequiresPriceApproval({
|
||||
status: 'PAID',
|
||||
deliveryType: 'delivery',
|
||||
deliveryFeeLocked: false,
|
||||
})
|
||||
|
||||
expect(result).toBe(false)
|
||||
})
|
||||
|
||||
it('returns false when delivery type is pickup', () => {
|
||||
const result = orderRequiresPriceApproval({
|
||||
status: 'PENDING_PAYMENT',
|
||||
deliveryType: 'pickup',
|
||||
deliveryFeeLocked: false,
|
||||
})
|
||||
|
||||
expect(result).toBe(false)
|
||||
})
|
||||
|
||||
it('returns false when delivery fee is locked', () => {
|
||||
const result = orderRequiresPriceApproval({
|
||||
status: 'PENDING_PAYMENT',
|
||||
deliveryType: 'delivery',
|
||||
deliveryFeeLocked: true,
|
||||
})
|
||||
|
||||
expect(result).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { OrderStatus } from '@/shared/constants/order'
|
||||
|
||||
type OrderPriceApprovalCandidate = {
|
||||
status: OrderStatus
|
||||
deliveryType: 'delivery' | 'pickup'
|
||||
deliveryFeeLocked: boolean
|
||||
}
|
||||
|
||||
export function orderRequiresPriceApproval(order: OrderPriceApprovalCandidate): boolean {
|
||||
return order.status === 'PENDING_PAYMENT' && order.deliveryType === 'delivery' && order.deliveryFeeLocked === false
|
||||
}
|
||||
Reference in New Issue
Block a user