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

import {
  resolveCreatedSmartEntryRecognitionItem
} from '../src/views/scripts/travelRequestDetailSmartEntryRecognition.js'

test('智能录入创建明细后跳过系统补贴行', () => {
  const createdItem = resolveCreatedSmartEntryRecognitionItem([
    {
      id: 'allowance-item',
      item_type: 'travel_allowance',
      invoice_id: ''
    },
    {
      id: 'business-item',
      item_type: 'travel',
      invoice_id: ''
    }
  ], new Set())

  assert.equal(createdItem?.id, 'business-item')
})

test('智能录入创建明细后没有可上传业务行时返回空', () => {
  const createdItem = resolveCreatedSmartEntryRecognitionItem([
    {
      id: 'allowance-item',
      item_type: 'travel_allowance',
      invoice_id: ''
    }
  ], new Set())

  assert.equal(createdItem, null)
})
