// test/util.test.js
import { getRealKeyData } from '../src/utils/util'
import { describe, expect, it } from '@jest/globals'

describe('getRealKeyData', () => {
  it('should return an object with keys after the first underscore', () => {
    const input = {
      prefix_key1: 'value1',
      a_prefix_key2: 'value2',
      key3: 'value3'
    }
    const expectedOutput = {
      key1: 'value1',
      prefix_key2: 'value2',
      key3: 'value3'
    }
    expect(getRealKeyData(input)).toEqual(expectedOutput)
  })

  it('should handle keys without underscores correctly', () => {
    const input = {
      key1: 'value1',
      key2: 'value2'
    }
    const expectedOutput = {
      key1: 'value1',
      key2: 'value2'
    }
    expect(getRealKeyData(input)).toEqual(expectedOutput)
  })

  it('should handle empty objects correctly', () => {
    const input = {}
    const expectedOutput = {}
    expect(getRealKeyData(input)).toEqual(expectedOutput)
  })
  it('test_report_render', () => {
    const inputList = [[{ rowSpan: 2, slotType: 'x-add-native-form', colSpan: 3, slotConfig: 'medOrderManaPForm', originalRowIndex: 0, type: 'slot', serviceName: 'af-his', events: [], originalCellIndex: 0, slotRef: 'left' }, [[{ rowSpan: 1, slotType: 'x-form-table', colSpan: 9, slotConfig: 'physicianOrderEntry', originalRowIndex: 0, type: 'slot', serviceName: 'af-his', originalCellIndex: 3, events: [], slotRef: 'top' }], [{ rowSpan: 1, slotType: 'x-tab', colSpan: 9, slotConfig: 'medOrderManaTab', originalRowIndex: 1, type: 'slot', serviceName: 'af-his', originalCellIndex: 3, events: [], slotRef: 'bottom' }]]], [{ rowSpan: 1, slotType: 'x-tab', colSpan: 9, slotConfig: 'medOrderManaTab', originalRowIndex: 1, type: 'slot', serviceName: 'af-his', originalCellIndex: 3, events: [], slotRef: 'bottom' }]]
    let operationIndex = 0
    let operationList = []
    for (const lst of inputList) {
      // 如果列表为空或只有一个元素，则所有元素相等。比较列表中每个元素是否与第一个元素相等
      if (lst.length >= 1 && !lst.every(x => Array.isArray(x) || Array.isArray(lst[0]) || x.rowSpan === lst[0].rowSpan)) {
        operationList = lst
        break // 使用 break 退出整个循环
      } else {
        // 被操作的行
        operationIndex += 1
      }
    }
    console.log('=====', operationIndex, operationList)
  })
})
