import assert from 'node:assert/strict'
import test from 'node:test'

import { resolveOutstandingDepositAmount } from './worker-platform/index.js'

test('resolveOutstandingDepositAmount deducts released and deducted history', () => {
  assert.equal(
    resolveOutstandingDepositAmount({
      frozen_amount: 20_000,
      released_amount: 5_000,
      deducted_amount: 3_000,
    }),
    12_000,
  )
})

test('resolveOutstandingDepositAmount never returns a negative deposit', () => {
  assert.equal(
    resolveOutstandingDepositAmount({
      frozen_amount: 10_000,
      released_amount: 12_000,
      deducted_amount: 1_000,
    }),
    0,
  )
  assert.equal(resolveOutstandingDepositAmount(null), 0)
})
