/* eslint-env jest */
import { searchToListOption } from '@vue2-client/services/v3Api'
import mockjs from 'mockjs'
import { describe, it, jest } from '@jest/globals' // Correct way to import mockjs

jest.mock('@vue2-client/utils/request', () => ({
  request: jest.fn(),
}))

jest.mock('@vue2-client/services/api/common', () => ({
  runLogic: jest.fn(),
}))

describe('searchToOption', () => {
  it('should transform data correctly when response has nested children', async () => {
    const params = { source: '获取部门', userid: '123', roleName: 'admin' }
    const mockResponse = mockjs.mock([
      {
        hasright: false,
        resourcetype: 'root',
        entitytype: 't_root',
        children: [
          {
            parentname: '资源管理',
            f_icon: 'tree_org',
            hasright: false,
            f_companylevel: '',
            resourcetype: 'organization',
            parentid: '3',
            number: '1',
            entitytype: 't_organization',
            f_description: '根组织',
            children: [
              {
                f_update_date: '2024-10-16 17:04:20',
                loginid: '15',
                parentname: '组织机构',
                f_icon: 'tree_org',
                hasright: false,
                f_companylevel: '',
                resourcetype: 'organization',
                parentid: '9',
                number: '',
                entitytype: 't_organization',
                f_description: 'standard_windows   QBJYangChun',
                children: [
                  {
                    f_dep_type: '营业厅',
                    f_update_date: '2023-09-08 18:54:17',
                    loginid: '124748',
                    parentname: '铜川天然气有限公司',
                    hasright: true,
                    f_remark: '',
                    resourcetype: 'department',
                    parentid: '37710',
                    entitytype: 't_department',
                    f_dep_id: '1111',
                    f_description: '',
                    oname: '中海石油气电集团有限责任公司测试',
                    children: [
                      {
                        f_dep_type: '部门',
                        f_update_date: '2023-08-30 22:59:51',
                        loginid: '122138',
                        parentname: '蜜雪冰城',
                        hasright: true,
                        f_remark: '',
                        resourcetype: 'department',
                        parentid: '218072726122921986',
                        entitytype: 't_department',
                        f_dep_id: '1111111',
                        f_description: '',
                        oname: '蜜雪冰城',
                        children: [],
                        f_create_date: '2023-08-29 11:10:14',
                        f_ldap_version: 25,
                        name: '测试',
                        selfid: '219413330547310593',
                        id: '219413330547310594',
                        position: 2,
                        fullname: '资源管理.组织机构.铜川天然气有限公司.蜜雪冰城.测试',
                        fullid: '3.9.37710.218072726122921986.219413330547310594',
                        tablename: 't_department',
                        haslicense: 'false'
                      }
                    ],
                    f_create_date: '2023-08-25 18:23:09',
                    f_ldap_version: 20,
                    name: '蜜雪冰城',
                    selfid: '218072726122921985',
                    id: '218072726122921986',
                    position: 2,
                    fullname: '资源管理.组织机构.铜川天然气有限公司.蜜雪冰城',
                    fullid: '3.9.37710.218072726122921986',
                    tablename: 't_department',
                    haslicense: 'false'
                  },
                  {
                    parentname: '铜川天然气有限公司',
                    f_icon: 'null',
                    f_remark: '',
                    parentid: '37710',
                    f_dep_id: '001',
                    onumber: '',
                    children: [],
                    selfid: '45501',
                    templatename: 'null',
                    id: '45500',
                    fullid: '3.9.37710.45500',
                    tablename: 't_department',
                    f_dep_type: '营业厅',
                    f_update_date: '2024-01-02 09:56:17',
                    loginid: '15',
                    hasright: true,
                    resourcetype: 'department',
                    entitytype: 't_department',
                    f_description: '',
                    oname: '乌海凯洁燃气有限责任公司',
                    f_ldap_version: 70,
                    name: '滨河营业厅',
                    position: 4,
                    fullname: '资源管理.组织机构.铜川天然气有限公司.滨河营业厅',
                    haslicense: 'false'
                  },
                  {
                    f_dep_type: '营业厅',
                    loginid: '15',
                    parentname: '铜川天然气有限公司',
                    f_icon: 'null',
                    hasright: true,
                    f_remark: '',
                    resourcetype: 'department',
                    parentid: '37710',
                    entitytype: 't_department',
                    f_dep_id: '003',
                    onumber: '',
                    f_description: '',
                    oname: '乌海凯洁燃气有限责任公司',
                    children: [],
                    f_ldap_version: 12,
                    name: '海南营业厅',
                    selfid: '45529',
                    templatename: 'null',
                    id: '45528',
                    position: 6,
                    fullname: '资源管理.组织机构.铜川天然气有限公司.海南营业厅',
                    fullid: '3.9.37710.45528',
                    tablename: 't_department',
                    haslicense: 'true'
                  },
                  {
                    f_dep_type: '部门',
                    loginid: '15',
                    parentname: '铜川天然气有限公司',
                    f_icon: 'null',
                    hasright: true,
                    f_remark: '',
                    resourcetype: 'department',
                    parentid: '37710',
                    entitytype: 't_department',
                    f_dep_id: '004',
                    onumber: '',
                    f_description: '',
                    oname: '乌海凯洁燃气有限责任公司',
                    children: [],
                    f_ldap_version: 4,
                    name: '海南政务大厅',
                    selfid: '45535',
                    templatename: 'null',
                    id: '45534',
                    position: 7,
                    fullname: '资源管理.组织机构.铜川天然气有限公司.海南政务大厅',
                    fullid: '3.9.37710.45534',
                    tablename: 't_department',
                    haslicense: 'true'
                  },
                  {
                    f_dep_type: '营业厅',
                    loginid: '15',
                    parentname: '铜川天然气有限公司',
                    f_icon: 'null',
                    hasright: true,
                    f_remark: '',
                    resourcetype: 'department',
                    parentid: '37710',
                    entitytype: 't_department',
                    f_dep_id: '005',
                    onumber: '',
                    f_description: '',
                    oname: '乌海凯洁燃气有限责任公司',
                    children: [],
                    f_ldap_version: 2,
                    name: '乌达营业厅',
                    selfid: '45541',
                    templatename: 'null',
                    id: '45540',
                    position: 8,
                    fullname: '资源管理.组织机构.铜川天然气有限公司.乌达营业厅',
                    fullid: '3.9.37710.45540',
                    tablename: 't_department',
                    haslicense: 'true'
                  },
                  {
                    f_dep_type: '营业厅',
                    loginid: '15',
                    parentname: '铜川天然气有限公司',
                    f_icon: 'null',
                    hasright: true,
                    f_remark: '',
                    resourcetype: 'department',
                    parentid: '37710',
                    entitytype: 't_department',
                    f_dep_id: '006',
                    onumber: '',
                    f_description: '',
                    oname: '乌海凯洁燃气有限责任公司',
                    children: [],
                    name: '乌达政务大厅',
                    selfid: '45547',
                    templatename: 'null',
                    id: '45546',
                    position: 9,
                    fullname: '资源管理.组织机构.铜川天然气有限公司.乌达政务大厅',
                    fullid: '3.9.37710.45546',
                    tablename: 't_department',
                    haslicense: 'true'
                  },
                  {
                    parentname: '铜川天然气有限公司',
                    f_icon: 'null',
                    f_remark: '',
                    parentid: '37710',
                    f_dep_id: '007',
                    onumber: '',
                    children: [],
                    selfid: '59877',
                    templatename: 'null',
                    id: '59876',
                    fullid: '3.9.37710.59876',
                    tablename: 't_department',
                    f_dep_type: '部门',
                    f_update_date: '2023-07-24 09:38:59',
                    loginid: '15',
                    hasright: true,
                    resourcetype: 'department',
                    entitytype: 't_department',
                    f_description: '',
                    oname: '巩义市燃气有限公司',
                    f_ldap_version: 25,
                    name: '客服中心1',
                    position: 13,
                    fullname: '资源管理.组织机构.铜川天然气有限公司.客服中心1',
                    haslicense: 'false'
                  },
                  {
                    f_dep_type: '部门',
                    loginid: '60530',
                    parentname: '铜川天然气有限公司',
                    hasright: true,
                    f_remark: '',
                    resourcetype: 'department',
                    parentid: '37710',
                    entitytype: 't_department',
                    f_dep_id: '008',
                    f_description: '',
                    oname: '乌海凯洁燃气有限责任公司',
                    children: [],
                    f_ldap_version: 2,
                    name: '城网中心',
                    selfid: '65856',
                    id: '65855',
                    position: 14,
                    fullname: '资源管理.组织机构.铜川天然气有限公司.城网中心',
                    fullid: '3.9.37710.65855',
                    tablename: 't_department',
                    haslicense: 'true'
                  },
                  {
                    f_dep_type: '部门',
                    f_update_date: '2023-07-24 09:48:50',
                    loginid: '124748',
                    parentname: '铜川天然气有限公司',
                    hasright: true,
                    f_remark: '',
                    resourcetype: 'department',
                    parentid: '37710',
                    entitytype: 't_department',
                    f_dep_id: '1025',
                    f_description: '',
                    oname: '巩义市燃气有限公司',
                    children: [],
                    f_create_date: '2023-07-24 09:39:21',
                    f_ldap_version: 25,
                    name: '客服中心',
                    selfid: '206344495946661889',
                    id: '206344495946661890',
                    position: 46,
                    fullname: '资源管理.组织机构.铜川天然气有限公司.客服中心',
                    fullid: '3.9.37710.206344495946661890',
                    tablename: 't_department',
                    haslicense: 'true'
                  },
                  {
                    f_dep_type: '部门',
                    f_update_date: '2023-12-15 10:00:03',
                    loginid: '122138',
                    parentname: '铜川天然气有限公司',
                    hasright: true,
                    f_remark: '',
                    resourcetype: 'department',
                    parentid: '37710',
                    entitytype: 't_department',
                    f_dep_id: '1314523',
                    f_description: '',
                    oname: ' 安康逸华天然气有限公司',
                    children: [],
                    f_create_date: '2023-12-15 09:51:36',
                    f_ldap_version: 7,
                    name: '安检部',
                    selfid: '258531431813349377',
                    id: '258531431813349378',
                    position: 51,
                    fullname: '资源管理.组织机构.铜川天然气有限公司.安检部',
                    fullid: '3.9.37710.258531431813349378',
                    tablename: 't_department',
                    haslicense: 'false'
                  },
                  {
                    f_dep_type: '部门',
                    f_update_date: '2024-07-19 11:43:14',
                    loginid: '15',
                    parentname: '铜川天然气有限公司',
                    hasright: true,
                    f_remark: '',
                    resourcetype: 'department',
                    parentid: '37710',
                    entitytype: 't_department',
                    f_dep_id: 'jypx',
                    f_description: '',
                    oname: '铜川天然气有限公司',
                    children: [
                      {
                        f_dep_type: '部门',
                        f_update_date: '2024-07-19 11:42:33',
                        loginid: '15',
                        parentname: '教育培训中心',
                        hasright: true,
                        f_remark: '',
                        resourcetype: 'department',
                        parentid: '337197440237174786',
                        entitytype: 't_department',
                        f_dep_id: 'kf',
                        f_description: '',
                        oname: '教育培训部',
                        children: [],
                        f_create_date: '2024-07-19 11:42:33',
                        f_ldap_version: 4,
                        name: '开发部',
                        selfid: '337197520834920449',
                        id: '337197520834920450',
                        position: 1,
                        fullname: '资源管理.组织机构.铜川天然气有限公司.教育培训中心.开发部',
                        fullid: '3.9.37710.337197440237174786.337197520834920450',
                        tablename: 't_department',
                        haslicense: 'false'
                      },
                      {
                        f_dep_type: '部门',
                        f_update_date: '2024-07-19 11:42:56',
                        loginid: '15',
                        parentname: '教育培训中心',
                        hasright: true,
                        f_remark: '',
                        resourcetype: 'department',
                        parentid: '337197440237174786',
                        entitytype: 't_department',
                        f_dep_id: 'xm',
                        f_description: '',
                        oname: '教育培训部',
                        children: [],
                        f_create_date: '2024-07-19 11:42:56',
                        f_ldap_version: 4,
                        name: '项目部',
                        selfid: '337197616142090241',
                        id: '337197616142090242',
                        position: 2,
                        fullname: '资源管理.组织机构.铜川天然气有限公司.教育培训中心.项目部',
                        fullid: '3.9.37710.337197440237174786.337197616142090242',
                        tablename: 't_department',
                        haslicense: 'false'
                      },
                      {
                        f_dep_type: '部门',
                        f_update_date: '2024-07-19 11:44:22',
                        loginid: '15',
                        parentname: '教育培训中心',
                        hasright: true,
                        f_remark: '',
                        resourcetype: 'department',
                        parentid: '337197440237174786',
                        entitytype: 't_department',
                        f_dep_id: 'xueyuan',
                        f_description: '',
                        oname: '教育培训中心',
                        children: [],
                        f_create_date: '2024-07-19 11:44:22',
                        f_ldap_version: 6,
                        name: '学员',
                        selfid: '337197976491524097',
                        id: '337197976491524098',
                        position: 4,
                        fullname: '资源管理.组织机构.铜川天然气有限公司.教育培训中心.学员',
                        fullid: '3.9.37710.337197440237174786.337197976491524098',
                        tablename: 't_department',
                        haslicense: 'false'
                      }
                    ],
                    f_create_date: '2024-07-19 11:42:14',
                    f_ldap_version: 13,
                    name: '教育培训中心',
                    selfid: '337197440237174785',
                    id: '337197440237174786',
                    position: 63,
                    fullname: '资源管理.组织机构.铜川天然气有限公司.教育培训中心',
                    fullid: '3.9.37710.337197440237174786',
                    tablename: 't_department',
                    haslicense: 'false'
                  }
                ],
                f_ldap_version: 181,
                name: '铜川天然气有限公司',
                selfid: '37711',
                templatename: 'organizationedit',
                id: '37710',
                position: 2,
                fullname: '资源管理.组织机构.铜川天然气有限公司',
                fullid: '3.9.37710',
                tablename: 't_organization',
                f_dir: 'standard'
              },
              {
                f_update_date: '2024-11-01 09:42:50',
                loginid: '15',
                parentname: '组织机构',
                f_serailport: '',
                f_icon: 'tree_org',
                hasright: false,
                f_companylevel: '',
                resourcetype: 'organization',
                parentid: '9',
                number: '123',
                entitytype: 't_organization',
                f_description: '',
                children: [
                  {
                    f_update_date: '2024-11-07 11:27:36',
                    loginid: '15',
                    parentname: 'LNG商贸公司',
                    f_serailport: '',
                    f_icon: 'tree_org',
                    hasright: false,
                    f_companylevel: '',
                    resourcetype: 'organization',
                    parentid: '130566',
                    number: '12',
                    entitytype: 't_organization',
                    f_description: '',
                    children: [
                      {
                        f_dep_type: '部门',
                        f_update_date: '2024-11-08 17:09:50',
                        loginid: '15',
                        parentname: '商贸公司',
                        hasright: true,
                        f_remark: '',
                        resourcetype: 'department',
                        parentid: '130568',
                        f_organization_id: '130566',
                        entitytype: 't_department',
                        f_dep_id: '测试',
                        f_description: '',
                        oname: '测试1',
                        children: [],
                        f_create_date: '2023-04-06 15:38:45',
                        f_ldap_version: 8,
                        name: '测试部门',
                        selfid: '130571',
                        id: '130570',
                        position: 1,
                        fullname: '资源管理.组织机构.LNG商贸公司.商贸公司.测试部门',
                        fullid: '3.9.130566.130568.130570',
                        tablename: 't_department',
                        haslicense: 'false'
                      },
                      {
                        f_dep_type: '部门',
                        f_update_date: '2024-11-07 11:28:06',
                        loginid: '15',
                        parentname: '商贸公司',
                        hasright: true,
                        f_remark: '',
                        resourcetype: 'department',
                        parentid: '130568',
                        f_organization_id: '130566',
                        entitytype: 't_department',
                        f_dep_id: '123',
                        f_description: '',
                        oname: '商贸公司',
                        children: [],
                        f_create_date: '2024-11-07 11:28:06',
                        f_ldap_version: 4,
                        name: '财务',
                        selfid: '377418936238604289',
                        id: '377418936238604290',
                        position: 4,
                        fullname: '资源管理.组织机构.LNG商贸公司.商贸公司.财务',
                        fullid: '3.9.130566.130568.377418936238604290',
                        tablename: 't_department',
                        haslicense: 'false'
                      }
                    ],
                    f_create_date: '2023-04-06 15:34:59',
                    f_ldap_version: 5,
                    name: '商贸公司',
                    selfid: '130569',
                    templatename: 'organizationedit',
                    id: '130568',
                    position: 1,
                    fullname: '资源管理.组织机构.LNG商贸公司.商贸公司',
                    fullid: '3.9.130566.130568',
                    tablename: 't_organization',
                    f_dir: 'standard'
                  }
                ],
                f_create_date: '2023-04-06 15:34:33',
                f_ldap_version: 8,
                name: 'LNG商贸公司',
                selfid: '130567',
                templatename: 'organizationedit',
                id: '130566',
                position: 5,
                fullname: '资源管理.组织机构.LNG商贸公司',
                fullid: '3.9.130566',
                tablename: 't_organization',
                f_dir: 'standard'
              },
              {
                f_update_date: '2023-06-28 15:23:19',
                loginid: '15',
                parentname: '组织机构',
                f_serailport: '',
                f_icon: 'tree_org',
                hasright: false,
                f_companylevel: '',
                resourcetype: 'organization',
                parentid: '9',
                entitytype: 't_organization',
                f_description: '',
                children: [
                  {
                    f_dep_type: '部门',
                    f_update_date: '2023-06-28 15:23:37',
                    loginid: '15',
                    parentname: '测试',
                    hasright: true,
                    f_remark: '',
                    resourcetype: 'department',
                    parentid: '197008974028079106',
                    entitytype: 't_department',
                    f_dep_id: '1211',
                    f_description: '',
                    oname: '测试',
                    children: [],
                    f_create_date: '2023-06-28 15:23:37',
                    f_ldap_version: 8,
                    name: '测试',
                    selfid: '197009050406354945',
                    id: '197009050406354946',
                    position: 1,
                    fullname: '资源管理.组织机构.测试.测试',
                    fullid: '3.9.197008974028079106.197009050406354946',
                    tablename: 't_department',
                    haslicense: 'false'
                  }
                ],
                f_create_date: '2023-06-28 15:23:19',
                f_ldap_version: 6,
                name: '测试',
                selfid: '197008974028079105',
                templatename: 'organizationedit',
                id: '197008974028079106',
                position: 6,
                fullname: '资源管理.组织机构.测试',
                fullid: '3.9.197008974028079106',
                tablename: 't_organization',
                f_dir: 'standard'
              },
              {
                f_update_date: '2023-08-18 10:01:37',
                loginid: '15',
                parentname: '组织机构',
                f_serailport: '',
                f_icon: 'tree_org',
                hasright: false,
                f_companylevel: '',
                resourcetype: 'organization',
                parentid: '9',
                entitytype: 't_organization',
                f_description: '',
                children: [
                  {
                    f_update_date: '2023-08-18 10:01:51',
                    loginid: '15',
                    parentname: '山西民生然气有限公司',
                    f_serailport: '',
                    f_icon: 'tree_org',
                    hasright: false,
                    f_companylevel: '',
                    resourcetype: 'organization',
                    parentid: '215409797858721794',
                    entitytype: 't_organization',
                    f_description: '',
                    children: [
                      {
                        f_dep_type: '部门',
                        f_update_date: '2023-08-18 10:02:28',
                        loginid: '15',
                        parentname: '运城民生然气有限公司',
                        hasright: true,
                        f_remark: '',
                        resourcetype: 'department',
                        parentid: '215409854339219458',
                        entitytype: 't_department',
                        f_dep_id: '1000111',
                        f_description: '',
                        oname: '运城民生然气有限公司',
                        children: [],
                        f_create_date: '2023-08-18 10:02:28',
                        f_ldap_version: 4,
                        name: '运城民生信息部',
                        selfid: '215410011734671361',
                        id: '215410011734671362',
                        position: 2,
                        fullname: '资源管理.组织机构.山西民生然气有限公司.运城民生然气有限公司.运城民生信息部',
                        fullid: '3.9.215409797858721794.215409854339219458.215410011734671362',
                        tablename: 't_department',
                        haslicense: 'true'
                      },
                      {
                        f_dep_type: '部门',
                        f_update_date: '2023-08-18 12:24:34',
                        loginid: '15',
                        parentname: '运城民生然气有限公司',
                        hasright: true,
                        f_remark: '',
                        resourcetype: 'department',
                        parentid: '215409854339219458',
                        entitytype: 't_department',
                        f_dep_id: '10001111',
                        f_description: '',
                        oname: '运城民生然气有限公司',
                        children: [],
                        f_create_date: '2023-08-18 12:24:34',
                        f_ldap_version: 4,
                        name: '营业厅',
                        selfid: '215445771426856961',
                        id: '215445771426856962',
                        position: 4,
                        fullname: '资源管理.组织机构.山西民生然气有限公司.运城民生然气有限公司.营业厅',
                        fullid: '3.9.215409797858721794.215409854339219458.215445771426856962',
                        tablename: 't_department',
                        haslicense: 'true'
                      },
                      {
                        f_dep_type: '部门',
                        f_update_date: '2023-08-18 12:25:41',
                        loginid: '15',
                        parentname: '运城民生然气有限公司',
                        hasright: true,
                        f_remark: '',
                        resourcetype: 'department',
                        parentid: '215409854339219458',
                        entitytype: 't_department',
                        f_dep_id: '123123',
                        f_description: '',
                        oname: '运城民生然气有限公司',
                        children: [],
                        f_create_date: '2023-08-18 12:25:41',
                        f_ldap_version: 4,
                        name: '安检部',
                        selfid: '215446052344561665',
                        id: '215446052344561666',
                        position: 5,
                        fullname: '资源管理.组织机构.山西民生然气有限公司.运城民生然气有限公司.安检部',
                        fullid: '3.9.215409797858721794.215409854339219458.215446052344561666',
                        tablename: 't_department',
                        haslicense: 'true'
                      },
                      {
                        f_dep_type: '部门',
                        f_update_date: '2023-08-18 12:26:00',
                        loginid: '15',
                        parentname: '运城民生然气有限公司',
                        hasright: true,
                        f_remark: '',
                        resourcetype: 'department',
                        parentid: '215409854339219458',
                        entitytype: 't_department',
                        f_dep_id: '12312313',
                        f_description: '',
                        oname: '运城民生然气有限公司',
                        children: [],
                        f_create_date: '2023-08-18 12:26:00',
                        f_ldap_version: 4,
                        name: '抄表部',
                        selfid: '215446129381343233',
                        id: '215446129381343234',
                        position: 6,
                        fullname: '资源管理.组织机构.山西民生然气有限公司.运城民生然气有限公司.抄表部',
                        fullid: '3.9.215409797858721794.215409854339219458.215446129381343234',
                        tablename: 't_department',
                        haslicense: 'true'
                      },
                      {
                        f_dep_type: '部门',
                        f_update_date: '2023-08-18 12:26:20',
                        loginid: '15',
                        parentname: '运城民生然气有限公司',
                        hasright: true,
                        f_remark: '',
                        resourcetype: 'department',
                        parentid: '215409854339219458',
                        entitytype: 't_department',
                        f_dep_id: '12313',
                        f_description: '',
                        oname: '运城民生然气有限公司',
                        children: [],
                        f_create_date: '2023-08-18 12:26:20',
                        f_ldap_version: 4,
                        name: '呼叫部',
                        selfid: '215446216610283521',
                        id: '215446216610283522',
                        position: 7,
                        fullname: '资源管理.组织机构.山西民生然气有限公司.运城民生然气有限公司.呼叫部',
                        fullid: '3.9.215409797858721794.215409854339219458.215446216610283522',
                        tablename: 't_department',
                        haslicense: 'true'
                      }
                    ],
                    f_create_date: '2023-08-18 10:01:51',
                    f_ldap_version: 18,
                    name: '运城民生然气有限公司',
                    selfid: '215409854339219457',
                    templatename: 'organizationedit',
                    id: '215409854339219458',
                    position: 1,
                    fullname: '资源管理.组织机构.山西民生然气有限公司.运城民生然气有限公司',
                    fullid: '3.9.215409797858721794.215409854339219458',
                    tablename: 't_organization',
                    f_dir: 'standard'
                  }
                ],
                f_create_date: '2023-08-18 10:01:37',
                f_ldap_version: 5,
                name: '山西民生然气有限公司',
                selfid: '215409797858721793',
                templatename: 'organizationedit',
                id: '215409797858721794',
                position: 8,
                fullname: '资源管理.组织机构.山西民生然气有限公司',
                fullid: '3.9.215409797858721794',
                tablename: 't_organization',
                f_dir: 'standard'
              },
              {
                f_update_date: '2023-09-13 10:29:31',
                loginid: '15',
                parentname: '组织机构',
                f_serailport: '',
                f_icon: 'tree_org',
                hasright: false,
                f_companylevel: '',
                resourcetype: 'organization',
                parentid: '9',
                entitytype: 't_organization',
                f_description: '',
                children: [
                  {
                    f_dep_type: '部门',
                    f_update_date: '2023-09-13 10:32:52',
                    loginid: '15',
                    parentname: '湖北利川靓力能源',
                    hasright: true,
                    f_remark: '',
                    resourcetype: 'department',
                    parentid: '224838903595663362',
                    entitytype: 't_department',
                    f_dep_id: '0913',
                    f_description: '',
                    oname: '湖北利川靓力能源',
                    children: [],
                    f_create_date: '2023-09-13 10:32:52',
                    f_ldap_version: 4,
                    name: '利川管理部',
                    selfid: '224839744440369153',
                    id: '224839744440369154',
                    position: 2,
                    fullname: '资源管理.组织机构.湖北利川靓力能源.利川管理部',
                    fullid: '3.9.224838903595663362.224839744440369154',
                    tablename: 't_department',
                    haslicense: 'false'
                  }
                ],
                f_create_date: '2023-09-13 10:29:31',
                f_ldap_version: 5,
                name: '湖北利川靓力能源',
                selfid: '224838903595663361',
                templatename: 'organizationedit',
                id: '224838903595663362',
                position: 9,
                fullname: '资源管理.组织机构.湖北利川靓力能源',
                fullid: '3.9.224838903595663362',
                tablename: 't_organization',
                f_dir: 'standard'
              },
              {
                f_update_date: '2024-04-18 16:38:43',
                loginid: '15',
                parentname: '组织机构',
                f_serailport: '',
                f_icon: 'tree_org',
                hasright: false,
                f_companylevel: '',
                resourcetype: 'organization',
                parentid: '9',
                entitytype: 't_organization',
                f_description: '',
                children: [
                  {
                    f_dep_type: '部门',
                    f_update_date: '2023-09-14 13:54:14',
                    loginid: '15',
                    parentname: '安康逸华天然气有限公司',
                    hasright: true,
                    f_remark: '',
                    resourcetype: 'department',
                    parentid: '225251125815803906',
                    entitytype: 't_department',
                    f_dep_id: '312',
                    f_description: '',
                    oname: '安康逸华天然气有限公司',
                    children: [],
                    f_create_date: '2023-09-14 13:48:26',
                    f_ldap_version: 11,
                    name: '客服中心',
                    selfid: '225251348680146945',
                    id: '225251348680146946',
                    position: 1,
                    fullname: '资源管理.组织机构.安康逸华天然气有限公司.客服中心',
                    fullid: '3.9.225251125815803906.225251348680146946',
                    tablename: 't_department',
                    haslicense: 'true'
                  }
                ],
                f_create_date: '2023-09-14 13:47:33',
                f_ldap_version: 8,
                name: '安康逸华天然气有限公司',
                selfid: '225251125815803905',
                templatename: 'organizationedit',
                id: '225251125815803906',
                position: 10,
                fullname: '资源管理.组织机构.安康逸华天然气有限公司',
                fullid: '3.9.225251125815803906',
                tablename: 't_organization',
                f_dir: 'QBJYangChun'
              }
            ],
            f_ldap_version: 15,
            name: '组织机构',
            selfid: '10',
            templatename: 'organizationedit',
            id: '9',
            position: 1,
            fullname: '资源管理.组织机构',
            fullid: '3.9',
            tablename: 't_organization',
            f_dir: 'standard'
          }
        ],
        f_ldap_version: 6,
        selfid: '4',
        name: '资源管理',
        templatename: '根节点编辑模板',
        position: 1,
        id: '3',
        fullname: '资源管理',
        fullid: '3',
        tablename: 't_root'
      }
    ])

    const { runLogic } = require('@vue2-client/services/api/common')
    runLogic.mockResolvedValue(mockResponse)

   await searchToListOption(params, (res) => console.log(res))
  })
})
describe('searchToOptionByRoleName', () => {
  it('should transform data correctly when response has nested children', async () => {
    const params = { source: '根据角色获取人员', userid: '123', roleName: '维修员' }
    const mockResponse = mockjs.mock([
      {
        qrcode: '/rs/user/getQRcode?QRCODE=5fd0-1725434115230-66711',
        roles: '67189,45552,70046,105861,59894,70154,56731,87803,282828514477080578,91090,206342877528326146,338699095533289474,86256,88883,89751',
        f_sex: '男',
        f_department_id: '45500',
        f_icon: 'tree_user',
        userid: '5fd0-1725434115230-66711',
        accesstime: '1731304553151',
        parentid: '45500',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2024-09-04 15:16:36',
        selfid: '354283617821786113',
        logindate: '2024-11-11 13:55:53',
        templatename: 'useredit',
        id: '354283617821786114',
        state: '在职',
        tablename: 't_user',
        f_update_date: '2024-09-04 15:16:36',
        login_address: '内网IP',
        loginid: '15',
        openid: 'oAVyg6hqc3735FUzBvggjlttYDBY',
        f_user_telephone: '',
        rolestr: '教培分管员,维修员,乌达区派单员,巡线员,营业员,呼叫员,管理员,安检员,客服中心管理员,审核员3,客服中心管理员（气价设置）,安检管理员,系统管理,测试营业员,收费员',
        loginnum: 0,
        f_age: '',
        resourcetype: 'user',
        f_organization_id: '37710',
        f_department_name: '滨河营业厅',
        ename: 'tangzenghui',
        entitytype: 't_user',
        f_description: '',
        loginip: '10.233.70.0',
        f_ldap_version: 39,
        name: '唐增辉',
        position: 41,
        haslicense: 'false',
        f_last_modification_time: '2024-09-04 15:16:36',
        forceoutstate: '1',
        f_role_name: '教培分管员 维修员 乌达区派单员 巡线员 营业员 呼叫员 管理员 安检员 客服中心管理员 审核员3 客服中心管理员（气价设置） 安检管理员 系统管理 测试营业员 收费员'
      },
      {
        qrcode: '/rs/user/getQRcode?QRCODE=123454343',
        roles: '56731,45552,129446,307848344640815106,338699095533289474,59894,88883,318800133091360770,217701711119253506',
        f_sex: '男',
        f_department_id: '45500',
        f_icon: 'tree_user',
        userid: '123454343',
        accesstime: '1730259861361',
        parentid: '45500',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2024-07-30 18:14:41',
        selfid: '341282471708590081',
        logindate: '2024-10-30',
        templatename: 'useredit',
        id: '341282471708590082',
        state: '在职',
        tablename: 't_user',
        f_update_date: '2024-07-30 18:14:41',
        login_address: '内网IP',
        loginid: '124748',
        f_user_telephone: '',
        rolestr: '管理员,营业员,呼叫员,维修员,教培分管员,巡线员,呼叫演示,安检管理,财务人员',
        loginnum: 0,
        f_age: '',
        resourcetype: 'user',
        f_organization_id: '37710',
        f_department_name: '滨河营业厅',
        ename: 'hwq',
        entitytype: 't_user',
        f_description: '',
        loginip: '10.233.70.0',
        f_ldap_version: 181,
        name: '何文强',
        position: 39,
        haslicense: 'false',
        f_last_modification_time: '2024-07-30 18:15:25',
        forceoutstate: '1',
        f_role_name: '管理员 营业员 呼叫员 维修员 教培分管员 巡线员 呼叫演示 安检管理 财务人员'
      },
      {
        qrcode: '/rs/user/getQRcode?QRCODE=1111000',
        roles: '67189,207801119064326146,215446483351240706,45552,70046,105861,59894,70154,215411057475321858,56731,126536,91090,126534,206342877528326146,88721,86256,88883,89751',
        f_sex: '男',
        f_department_id: '45500',
        f_icon: 'tree_user',
        userid: '1111000',
        accesstime: '1712654582914',
        parentid: '45500',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2024-04-09 17:21:40',
        selfid: '300681687845699585',
        logindate: '2024-04-09',
        templatename: 'useredit',
        id: '300681687845699586',
        state: '在职',
        tablename: 't_user',
        f_update_date: '2024-04-09 17:21:40',
        login_address: '内网IP',
        loginid: '15',
        f_user_telephone: '',
        rolestr: '维修员,海勃湾区派单员,营业员,呼叫员,安检员,管理员,客服中心管理员,审核员3,客服中心管理员（气价设置）,安检管理员,系统管理,测试营业员,收费员,市场部报装,市场部派工,管理员,信息部管理员,营业员',
        loginnum: 0,
        f_age: '',
        resourcetype: 'user',
        f_organization_id: '37710',
        f_department_name: '滨河营业厅',
        ename: 'msj',
        entitytype: 't_user',
        f_description: '',
        loginip: '192.168.150.170',
        f_ldap_version: 24,
        name: '马三金',
        position: 31,
        haslicense: 'false',
        f_last_modification_time: '2024-04-09 17:22:48',
        forceoutstate: '1',
        f_role_name: '维修员 海勃湾区派单员 营业员 呼叫员 安检员 管理员 客服中心管理员 审核员3 客服中心管理员（气价设置） 安检管理员 系统管理 测试营业员 收费员 市场部报装 市场部派工 管理员 信息部管理员 营业员'
      },
      {
        qrcode: '/rs/user/getQRcode?QRCODE=123456',
        roles: '128078,67189,127566,126542,59894,127564,192684790586146817,126540,127562,127560,126538,126536,126534,128944,88883,128946,89751',
        f_sex: '男',
        f_department_id: '45500',
        f_icon: 'tree_user',
        userid: '123456',
        accesstime: '1705396824637',
        parentid: '45500',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2023-12-25 13:57:39',
        selfid: '262217231268708353',
        logindate: '2024-01-16',
        templatename: 'useredit',
        id: '262217231268708354',
        state: '在职',
        tablename: 't_user',
        f_update_date: '2023-12-25 13:57:39',
        login_address: 'XX XX',
        loginid: '122138',
        f_user_telephone: '',
        rolestr: '安检员,管理员,维修员,系统管理,市场部报装,市场部派工,运营部派工,工程部派工,抄表员,工程部报装,运营部报装,设计部报装,图纸审核,派单员,子公司市场部报装,营业厅报装,规划部报装',
        loginnum: 0,
        f_age: '',
        resourcetype: 'user',
        f_organization_id: '37710',
        f_department_name: '滨河营业厅',
        ename: 'sycs',
        entitytype: 't_user',
        f_description: '',
        loginip: '61.150.11.26',
        f_ldap_version: 29,
        name: '泗阳试用',
        position: 24,
        haslicense: '',
        f_last_modification_time: '2023-12-25 13:57:39',
        forceoutstate: '1',
        f_role_name: '安检员 管理员 维修员 系统管理 市场部报装 市场部派工 运营部派工 工程部派工 抄表员 工程部报装 运营部报装 设计部报装 图纸审核 派单员 子公司市场部报装 营业厅报装 规划部报装'
      },
      {
        f_department_id: '45534',
        userid: '125306',
        f_show_rolestr: 'null',
        loginnumber: 'null',
        number: '125306',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2022-12-14 16:06:31',
        selfid: '128029',
        logindate: '2024-11-13 12:46:45',
        id: '128028',
        state: '在职',
        f_user_macip: 'null',
        loginid: 'null',
        openid: 'oAVyg6gB_qw34GIp2vRukDYk4eYM',
        f_user_telephone: '1111111111',
        f_organization_id: '37710',
        ename: 'nice',
        entitytype: 't_user',
        loginip: '10.233.70.0',
        name: '张振宇',
        position: 23,
        haslicense: 'true',
        forceoutstate: '1',
        f_show_department_name: 'null',
        f_mac_adress: 'null',
        qrcode: '/rs/user/getQRcode?QRCODE=125306',
        roles: '128078,45552,129446,105861,267297154459107330,126542,59894,122468,126536,91090,126534,88883,89751',
        f_sex: '男',
        f_icon: 'tree_user',
        accesstime: '1731473205094',
        parentid: '45534',
        templatename: 'useredit',
        f_old_userid: 'null',
        tablename: 't_user',
        f_update_date: '2024-07-26 17:04:32',
        login_address: '内网IP',
        ticket: 'null',
        imgid: 'null',
        rolestr: '巡线管理员,派单员,测试营业员,巡线员,收费员,王三石,抄表员,管理员,维修员,系统管理,营业员,市场部报装,市场部派工',
        loginnum: 0,
        f_age: '',
        resourcetype: 'user',
        url: 'null',
        f_department_name: '海南政务大厅',
        deleted: 'false',
        f_description: '',
        f_ldap_version: 1211,
        f_extend2: 'null',
        f_last_modification_time: '2024-07-28 21:00:30',
        f_role_name: '巡线管理员 派单员 测试营业员 巡线员 收费员 王三石 抄表员 管理员 维修员 系统管理 营业员 市场部报装 市场部派工',
        f_extend1: 'null'
      },
      {
        qrcode: '/rs/user/getQRcode?QRCODE=4a8e-1707299074649-86255',
        roles: '56731,87803,67189,45552,88721,59894,88883',
        f_sex: '男',
        f_department_id: '45500',
        f_icon: 'tree_user',
        userid: '4a8e-1707299074649-86255',
        accesstime: '1707299662006',
        parentid: '45500',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2024-02-07 17:45:01',
        selfid: '278219514364166145',
        logindate: '2024-08-22',
        templatename: 'useredit',
        id: '278219514364166146',
        state: '在职',
        tablename: 't_user',
        f_update_date: '2024-02-07 17:45:01',
        login_address: 'XX XX',
        loginid: '15',
        f_user_telephone: '',
        rolestr: '乌达区派单员,营业员,呼叫员,维修员,海勃湾区派单员,管理员,安检员',
        loginnum: 1,
        f_age: '',
        resourcetype: 'user',
        f_organization_id: '37710',
        f_department_name: '滨河营业厅',
        ename: 'd',
        entitytype: 't_user',
        f_description: '',
        loginip: '61.150.11.113',
        f_ldap_version: 12,
        name: '111',
        position: 21,
        haslicense: 'false',
        f_last_modification_time: '2024-02-07 17:45:01',
        forceoutstate: '1',
        f_role_name: '乌达区派单员 营业员 呼叫员 维修员 海勃湾区派单员 管理员 安检员'
      },
      {
        f_show_department_name: '',
        f_mac_adress: 'null',
        qrcode: '/rs/user/getQRcode?QRCODE=9702-1681349451451-67948',
        roles: '105861,56731,88883,126542,128960,70046,89751,70154',
        f_sex: '男',
        f_icon: 'tree_user',
        userid: '9702-1681349451451-67948',
        accesstime: '1716780093913',
        f_show_rolestr: 'null',
        parentid: '59876',
        loginnumber: 'null',
        number: '9702-1681349451451-67948',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2023-04-13 09:32:21',
        selfid: '130971',
        logindate: '2024-05-27',
        templatename: 'useredit',
        f_old_userid: 'null',
        id: '130970',
        state: '在职',
        tablename: 't_user',
        f_user_macip: 'null',
        f_update_date: '2023-04-13 11:18:28',
        login_address: '内网IP',
        loginid: '130304',
        ticket: 'null',
        imgid: 'null',
        f_user_telephone: '',
        rolestr: '收费员,呼叫员,维修员,抄表员,派单员,客服中心管理员,系统管理,客服中心管理员（气价设置）',
        loginnum: 0,
        f_age: '',
        resourcetype: 'user',
        url: 'null',
        f_department_name: '客服中心',
        ename: 'sh',
        deleted: 'false',
        entitytype: 't_user',
        f_description: '',
        loginip: '192.168.50.69',
        f_ldap_version: 2,
        name: '收费员/话务员',
        position: 20,
        haslicense: '',
        f_extend2: 'null',
        forceoutstate: '1',
        f_role_name: '收费员 呼叫员 维修员 抄表员 派单员 客服中心管理员 系统管理 客服中心管理员（气价设置） ',
        f_extend1: 'null'
      },
      {
        f_department_id: '45528',
        userid: 'f272-1669095547564-67004',
        f_show_rolestr: 'null',
        loginnumber: 'null',
        number: 'f272-1669095547564-67004',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2022-11-22 13:40:05',
        selfid: '122441',
        logindate: '2024-06-27',
        id: '122440',
        state: '在职',
        f_user_macip: 'null',
        loginid: '15',
        f_user_telephone: '',
        f_organization_id: '37710',
        ename: 'csgy',
        entitytype: 't_user',
        loginip: '192.168.50.67',
        name: '测试公用',
        position: 20,
        haslicense: 'false',
        forceoutstate: '1',
        f_show_department_name: 'null',
        f_mac_adress: 'null',
        qrcode: '/rs/user/getQRcode?QRCODE=f272-1669095547564-67004',
        roles: '59894,88883,56731,67189',
        f_sex: '男',
        f_icon: 'tree_user',
        accesstime: '1719468188254',
        parentid: '45528',
        templatename: 'useredit',
        f_old_userid: 'null',
        tablename: 't_user',
        f_update_date: '2024-01-19 08:36:45',
        login_address: '内网IP',
        ticket: 'null',
        imgid: 'null',
        rolestr: '管理员,维修员,呼叫员,安检员',
        loginnum: 0,
        f_age: '',
        resourcetype: 'user',
        url: 'null',
        f_department_name: '海南营业厅',
        deleted: 'false',
        f_description: '',
        f_ldap_version: 486,
        f_extend2: 'null',
        f_role_name: '管理员 维修员 呼叫员 安检员',
        f_extend1: 'null'
      },
      {
        userid: '1d91-1669088967031-19905',
        f_show_rolestr: 'null',
        loginnumber: 'null',
        number: '1d91-1669088967031-19905',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2022-11-22 11:50:52',
        selfid: '122139',
        logindate: '2024-11-13 11:36:39',
        id: '122138',
        state: '在职',
        f_user_macip: 'null',
        loginid: '15',
        f_user_telephone: '',
        ename: 'admin2',
        entitytype: 't_user',
        loginip: '10.233.70.0',
        name: '管理员',
        position: 18,
        haslicense: 'false',
        forceoutstate: '1',
        f_show_department_name: 'null',
        f_mac_adress: 'null',
        qrcode: '/api/af-system/ldapUser/getQRcode?QRCODE=1d91-1669088967031-19905',
        roles: '67189,70046,45552,128960,105861,126542,59894,70154,56731,282830844236791810,87803,282828514477080578,91090,289084445410066434,88721,282829989592825858,86256,88883,89751',
        f_sex: '男',
        f_icon: 'tree_user',
        accesstime: '1731468999430',
        parentid: '45500',
        templatename: 'useredit',
        f_old_userid: 'null',
        tablename: 't_user',
        f_update_date: '2024-11-04 16:57:22',
        login_address: '内网IP',
        ticket: 'null',
        imgid: 'null',
        rolestr: '安检员,客服中心管理员,营业员,收费员,抄表员,管理员,客服中心管理员（气价设置）,呼叫员,需要定位人员,乌达区派单员,巡线员,测试营业员,抄表员,海勃湾区派单员,巡线管理员,安检管理员,维修员,系统管理,派单员',
        loginnum: 0,
        f_age: '',
        resourcetype: 'user',
        url: 'null',
        f_department_name: '滨河营业厅',
        deleted: 'false',
        f_description: '',
        f_ldap_version: 11091,
        f_extend2: 'null',
        f_last_modification_time: '2024-07-29 09:25:03',
        f_role_name: '安检员 客服中心管理员 营业员 收费员 抄表员 管理员 客服中心管理员（气价设置） 呼叫员 需要定位人员 乌达区派单员 巡线员 测试营业员 抄表员 海勃湾区派单员 巡线管理员 安检管理员 维修员 系统管理 派单员',
        f_extend1: 'null'
      },
      {
        qrcode: '/rs/user/getQRcode?QRCODE=7b73-1693795543334-75047',
        roles: '128078,67189,45552,128960,127566,126542,59894,126540,127562,318800133091360770,127560,56731,122468,126538,126536,126534,128944,88883,128946',
        f_sex: '男',
        f_department_id: '45500',
        f_icon: 'tree_user',
        userid: '7b73-1693795543334-75047',
        accesstime: '1724485084261',
        parentid: '45500',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2023-09-04 10:46:52',
        selfid: '221581777473503233',
        logindate: '2024-08-24',
        templatename: 'useredit',
        id: '221581777473503234',
        state: '在职',
        tablename: 't_user',
        f_update_date: '2024-05-29 17:18:31',
        login_address: '内网IP',
        loginid: '122440',
        imgid: 'null',
        f_user_telephone: '',
        rolestr: '派单员,安检员,营业员,派单员,图纸审核,抄表员,管理员,工程部派工,运营部报装,工程部报装,呼叫员,巡线管理员,运营部派工,市场部派工,市场部报装,子公司市场部报装,维修员,营业厅报装,财务人员',
        loginnum: 0,
        f_age: '',
        resourcetype: 'user',
        f_organization_id: '37710',
        f_department_name: '滨河营业厅',
        ename: 'csgy222',
        entitytype: 't_user',
        f_description: '',
        loginip: '192.168.50.4',
        f_ldap_version: 259,
        name: '测试公用222',
        position: 17,
        haslicense: 'true',
        f_last_modification_time: '2024-04-01 13:52:09',
        forceoutstate: '1',
        f_role_name: '派单员 安检员 营业员 派单员 图纸审核 抄表员 管理员 工程部派工 运营部报装 工程部报装 呼叫员 巡线管理员 运营部派工 市场部派工 市场部报装 子公司市场部报装 维修员 营业厅报装 财务人员'
      },
      {
        f_show_department_name: 'null',
        f_mac_adress: 'null',
        qrcode: '/rs/user/getQRcode?QRCODE=0817',
        roles: '126542,105861,91090,70154,70046,59894,88883,67189,56731,86256,45552',
        f_sex: '男',
        f_icon: 'tree_user',
        userid: '0817',
        accesstime: '1713862375320',
        f_show_rolestr: 'null',
        parentid: '45540',
        loginnumber: 'null',
        number: '0817',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2023-03-31 15:24:15',
        selfid: '130317',
        logindate: '2024-04-23',
        templatename: 'useredit',
        f_old_userid: 'null',
        id: '130316',
        state: '在职',
        tablename: 't_user',
        f_user_macip: 'null',
        f_update_date: '2023-04-23 11:09:51',
        login_address: '内网IP',
        loginid: '124748',
        ticket: 'null',
        imgid: 'null',
        f_user_telephone: '',
        rolestr: '抄表员,收费员,测试营业员,客服中心管理员（气价设置）,客服中心管理员,管理员,维修员,安检员,呼叫员,安检管理员,营业员',
        loginnum: 1,
        f_age: '',
        resourcetype: 'user',
        url: 'null',
        f_department_name: '乌达营业厅',
        ename: 'ljc',
        deleted: 'false',
        entitytype: 't_user',
        f_description: '',
        loginip: '10.233.70.0',
        f_ldap_version: 37,
        name: 'lichen',
        position: 17,
        haslicense: 'true',
        f_extend2: 'null',
        forceoutstate: '1',
        f_role_name: '抄表员 收费员 测试营业员 客服中心管理员（气价设置） 客服中心管理员 管理员 维修员 安检员 呼叫员 安检管理员 营业员 ',
        f_extend1: 'null'
      },
      {
        qrcode: '/rs/user/getQRcode?QRCODE=2c95-1692498432984-95557',
        roles: '67189,128960,219889170502516738,86256,88883',
        f_sex: '男',
        f_department_id: '45500',
        f_icon: 'tree_user',
        userid: '2c95-1692498432984-95557',
        accesstime: '1726911937832',
        parentid: '45500',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2023-08-20 10:28:10',
        selfid: '216141253706907649',
        logindate: '2024-09-21',
        templatename: 'useredit',
        id: '216141253706907650',
        state: '在职',
        tablename: 't_user',
        f_update_date: '2023-09-07 09:35:42',
        login_address: '内网IP',
        loginid: '122138',
        imgid: 'null',
        f_user_telephone: '',
        rolestr: '派单员,演示,维修员,安检管理员,安检员',
        loginnum: 0,
        f_age: '',
        resourcetype: 'user',
        f_organization_id: '37710',
        f_department_name: '滨河营业厅',
        ename: 'ysh',
        entitytype: 't_user',
        f_description: '',
        loginip: '10.233.70.0',
        f_ldap_version: 100,
        name: '测试演示号',
        position: 16,
        haslicense: 'false',
        f_last_modification_time: '2023-09-06 19:46:58',
        forceoutstate: '1',
        f_role_name: '派单员 演示 维修员 安检管理员 安检员'
      },
      {
        qrcode: '/rs/user/getQRcode?QRCODE=1835-1725334332969-36311',
        roles: '88883',
        f_sex: '男',
        f_department_id: '45528',
        f_icon: 'tree_user',
        userid: '1835-1725334332969-36311',
        accesstime: '1731465819654',
        parentid: '45528',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2024-09-03 11:32:56',
        selfid: '353864941641531393',
        logindate: '2024-11-13 10:43:39',
        templatename: 'useredit',
        id: '353864941641531394',
        state: '在职',
        tablename: 't_user',
        f_update_date: '2024-09-03 11:32:56',
        login_address: '内网IP',
        loginid: '122138',
        f_user_telephone: '',
        rolestr: '维修员',
        loginnum: 0,
        f_age: '',
        resourcetype: 'user',
        f_organization_id: '37710',
        f_department_name: '海南营业厅',
        ename: 'mm',
        entitytype: 't_user',
        f_description: '',
        loginip: '10.233.70.0',
        f_ldap_version: 21,
        name: '测试密码',
        position: 16,
        haslicense: 'false',
        f_last_modification_time: '2024-09-03 11:34:05',
        forceoutstate: '1',
        f_role_name: '维修员'
      },
      {
        qrcode: '/rs/user/getQRcode?QRCODE=dssasd',
        roles: '88883,87803,88721,45552,59894,67189,70046,70154,86256,89751,91090,105861',
        f_sex: '男',
        f_department_id: '123140',
        f_icon: 'tree_user',
        userid: 'dssasd',
        accesstime: '1725465136539',
        parentid: '45500',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2023-05-17 16:00:15',
        selfid: '135809',
        logindate: '2024-09-04',
        templatename: 'useredit',
        id: '135808',
        state: '在职',
        tablename: 't_user',
        f_update_date: '2023-05-17 16:00:15',
        login_address: '内网IP',
        loginid: '123140',
        f_user_telephone: '',
        rolestr: '维修员,乌达区派单员,海勃湾区派单员,营业员,管理员,安检员,客服中心管理员,客服中心管理员（气价设置）,安检管理员,系统管理,测试营业员,收费员',
        loginnum: 0,
        f_age: '',
        resourcetype: 'user',
        f_organization_id: '123138',
        f_department_name: '滨河营业厅',
        ename: 'rs',
        deleted: 'false',
        entitytype: 't_user',
        f_description: '',
        loginip: '10.233.70.0',
        f_ldap_version: 3,
        name: 'ss',
        position: 15,
        haslicense: 'true',
        forceoutstate: '1',
        f_role_name: '维修员 乌达区派单员 海勃湾区派单员 营业员 管理员 安检员 客服中心管理员 客服中心管理员（气价设置） 安检管理员 系统管理 测试营业员 收费员 '
      },
      {
        qrcode: '/rs/user/getQRcode?QRCODE=xiaozhang',
        roles: '45552,59894,88883',
        f_sex: '男',
        f_department_id: '59876',
        f_icon: 'tree_user',
        userid: 'xiaozhang',
        accesstime: '1687936733696',
        parentid: '59876',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2023-06-28 15:18:46',
        selfid: '197007828257472513',
        templatename: 'useredit',
        id: '197007828257472514',
        state: '在职',
        tablename: 't_user',
        f_update_date: '2023-06-28 15:18:46',
        login_address: 'XX XX',
        loginid: '124748',
        f_user_telephone: '',
        rolestr: '维修员,营业员,管理员',
        loginnum: 0,
        f_age: '',
        resourcetype: 'user',
        f_organization_id: '37710',
        f_department_name: '客服中心',
        ename: 'qwer',
        entitytype: 't_user',
        f_description: '',
        loginip: '61.150.11.245',
        f_ldap_version: 6,
        name: 'zhang',
        position: 14,
        haslicense: '',
        f_last_modification_time: '2023-06-28 15:18:46',
        forceoutstate: '1',
        f_role_name: '维修员 营业员 管理员'
      },
      {
        qrcode: '/rs/user/getQRcode?QRCODE=23123',
        roles: '67189,225247545964756994,225330026290216962,88883',
        f_sex: '男',
        f_department_id: '206344495946661890',
        f_icon: 'tree_user',
        userid: '23123',
        accesstime: '1721714807310',
        parentid: '206344495946661890',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2023-09-14 15:29:48',
        selfid: '225276856495112193',
        logindate: '2024-07-23',
        templatename: 'useredit',
        id: '225276856495112194',
        state: '在职',
        tablename: 't_user',
        f_update_date: '2023-12-15 10:47:39',
        login_address: '内网IP',
        loginid: '15',
        imgid: 'null',
        f_user_telephone: '',
        rolestr: '安检员,安检呼叫演示,维修员,安检员',
        loginnum: 0,
        f_age: '',
        resourcetype: 'user',
        f_organization_id: '37710',
        f_department_name: '客服中心',
        ename: 'xtys',
        entitytype: 't_user',
        f_description: '',
        loginip: '192.168.50.69',
        f_ldap_version: 47,
        name: '系统演示',
        position: 5,
        haslicense: '',
        f_last_modification_time: '2023-09-14 15:29:48',
        forceoutstate: '1',
        f_role_name: '安检员 安检呼叫演示 维修员 安检员'
      },
      {
        f_department_id: '218072726122921986',
        userid: 'lzq11',
        number: 'lzq11',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2024-04-26 10:11:48',
        selfid: '306734101812084737',
        logindate: '2024-11-11 17:52:37',
        id: '306734101812084738',
        state: '在职',
        loginid: '15',
        f_user_telephone: '',
        count: '1',
        f_organization_id: '37710',
        ename: 'lzq11',
        loginonline: '1',
        entitytype: 't_user',
        tusid: '306734101812084738',
        organizationname: '铜川天然气有限公司',
        loginip: '10.233.70.0',
        name: 'lzq11',
        position: '4',
        haslicense: 'true',
        tdid: '218072726122921986',
        forceoutstate: '1',
        qrcode: '/api/af-system/ldapUser/getQRcode?QRCODE=lzq11',
        roles: '378952574012882946,67189,70046,45552,105861,126542,70154,59894,318800133091360770,56731,87803,91090,344842995125846018,86256,88883,89751,378964491590828032',
        f_sex: '男',
        f_icon: 'tree_user',
        accesstime: '1731318757940',
        parentid: '218072726122921986',
        f_dep_id: '1111',
        templatename: 'useredit',
        tablename: 't_user',
        f_update_date: '2024-11-11 17:50:13',
        login_address: '内网IP',
        imgid: 'null',
        tosid: '37710',
        rolestr: '置换员,安检员,客服中心管理员,营业员,收费员,抄表员,客服中心管理员（气价设置）,管理员,财务人员,呼叫员,乌达区派单员,测试营业员,拉黑员,安检管理员,维修员,系统管理,施工员',
        tuid: '306734101812084738',
        loginnum: '1',
        f_age: '',
        resourcetype: 'user',
        f_department_name: '蜜雪冰城',
        f_description: '',
        f_ldap_version: 634,
        online: '1',
        f_last_modification_time: '2024-09-02 10:55:51',
        f_role_name: '置换员 安检员 客服中心管理员 营业员 收费员 抄表员 客服中心管理员（气价设置） 管理员 财务人员 呼叫员 乌达区派单员 测试营业员 拉黑员 安检管理员 维修员 系统管理 施工员'
      },
      {
        qrcode: '/rs/user/getQRcode?QRCODE=12127',
        roles: '88883',
        f_sex: '男',
        f_department_id: '45500',
        f_icon: 'tree_user',
        userid: '12127',
        accesstime: '0',
        parentid: '45500',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2023-06-26 16:02:23',
        selfid: '196294028432637953',
        templatename: 'useredit',
        id: '196294028432637954',
        state: '在职',
        tablename: 't_user',
        f_update_date: '2023-09-08 18:51:44',
        login_address: 'XX XX',
        loginid: '122138',
        imgid: 'null',
        f_user_telephone: '',
        rolestr: '维修员',
        loginnum: 0,
        f_age: '',
        resourcetype: 'user',
        f_organization_id: '37710',
        f_department_name: '滨河营业厅',
        ename: 'weixiu',
        entitytype: 't_user',
        f_description: '',
        loginip: '61.150.11.245',
        f_ldap_version: 6,
        name: '维修员',
        position: 4,
        haslicense: '',
        f_last_modification_time: '2023-06-26 16:02:23',
        forceoutstate: '1',
        f_role_name: '维修员'
      },
      {
        qrcode: '/rs/user/getQRcode?QRCODE=73c5-1714362546229-39826',
        roles: '67189,282828514477080578,129446,307848344640815106,225330026290216962,282829989592825858,86256,88883',
        f_sex: '男',
        f_department_id: '258531431813349378',
        f_icon: 'tree_user',
        userid: '73c5-1714362546229-39826',
        accesstime: '1714373274680',
        parentid: '258531431813349378',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2024-04-29 11:51:09',
        selfid: '307846266581286913',
        logindate: '2024-04-29',
        templatename: 'useredit',
        id: '307846266581286914',
        state: '在职',
        tablename: 't_user',
        f_update_date: '2024-04-29 12:03:17',
        login_address: '内网IP',
        loginid: '15',
        imgid: 'null',
        f_user_telephone: '',
        rolestr: '维修员,巡线员,巡线管理员,安检员,安检管理员,巡线员,安检员,安检管理',
        loginnum: 0,
        f_age: '',
        resourcetype: 'user',
        f_organization_id: '37710',
        f_department_name: '安检部',
        ename: 'xscs',
        entitytype: 't_user',
        f_description: '',
        loginip: '192.168.50.69',
        f_ldap_version: 34,
        name: 'xscs',
        position: 2,
        haslicense: 'true',
        f_last_modification_time: '2024-04-29 11:51:09',
        forceoutstate: '1',
        f_role_name: '安检员 巡线员 巡线员 安检管理 安检员 巡线管理员 安检管理员 维修员 管理员 '
      },
      {
        f_show_department_name: '',
        qrcode: '/rs/user/getQRcode?QRCODE=3c1f-1646967713676-00707',
        roles: '88883',
        f_sex: '男',
        f_icon: 'tree_user',
        userid: '3c1f-1646967713676-00707',
        accesstime: '1697079377785',
        f_show_rolestr: '',
        parentid: '87791',
        password: '**********',
        f_idnumber: '',
        selfid: '89584',
        logindate: '2023-10-12',
        templatename: 'useredit',
        id: '89583',
        state: '在职',
        tablename: 't_user',
        login_address: 'XX XX',
        loginid: '15',
        imgid: 'null',
        f_user_telephone: '',
        rolestr: '维修员',
        loginnum: 0,
        f_age: '',
        resourcetype: 'user',
        f_department_name: '海勃湾区维修',
        ename: 'bhwx',
        deleted: 'false',
        entitytype: 't_user',
        f_description: '',
        loginip: '61.150.11.245',
        f_ldap_version: 3,
        name: '滨河维修',
        position: 2,
        haslicense: 'true',
        forceoutstate: '1',
        f_role_name: '维修员 '
      },
      {
        userid: '2609-1641179761502-53217',
        f_show_rolestr: '',
        loginnumber: 'null',
        number: '2609-1641179761502-53217',
        password: '**********',
        f_idnumber: '',
        f_create_date: 'null',
        selfid: '60531',
        logindate: '2024-11-05',
        id: '60530',
        state: '在职',
        f_user_macip: 'null',
        loginid: '15',
        f_user_telephone: '',
        ename: 'xtgly',
        entitytype: 't_user',
        loginip: '10.233.70.0',
        name: '系统管理员',
        position: 1,
        haslicense: 'true',
        forceoutstate: '1',
        f_show_department_name: '',
        f_mac_adress: 'null',
        qrcode: '/api/af-system/ldapUser/getQRcode?QRCODE=2609-1641179761502-53217',
        roles: '307477876545028098,67189,45552,70046,105861,126542,59894,70154,56731,87803,329663362722037762,91090,289084445410066434,88721,86256,88883,89751',
        f_sex: '男',
        f_icon: 'tree_user',
        accesstime: '0',
        parentid: '59876',
        templatename: 'useredit',
        f_old_userid: 'null',
        tablename: 't_user',
        f_update_date: '2024-11-07 10:11:19',
        login_address: '内网IP',
        ticket: 'null',
        imgid: 'null',
        rolestr: '报建收费,安检员,营业员,客服中心管理员,收费员,管理员,客服中心管理员（气价设置）,呼叫员,乌达区派单员,限时登录,测试营业员,海勃湾区派单员,安检管理员,维修员,系统管理,抄表员,抄表员',
        loginnum: 1,
        f_age: '',
        resourcetype: 'user',
        url: 'null',
        f_department_name: '客服中心',
        deleted: 'false',
        f_description: '1',
        f_ldap_version: 799,
        f_extend2: 'null',
        f_last_modification_time: '2024-08-02 10:35:03',
        f_role_name: '报建收费 安检员 营业员 客服中心管理员 收费员 管理员 客服中心管理员（气价设置） 呼叫员 乌达区派单员 限时登录 测试营业员 海勃湾区派单员 安检管理员 维修员 系统管理 抄表员 抄表员',
        f_extend1: 'null'
      },
      {
        qrcode: '/rs/user/getQRcode?QRCODE=1009231',
        roles: '224839384405508098,303935828395163650,59894,88883,89751',
        f_sex: '男',
        f_department_id: '303935382460956674',
        f_icon: 'tree_user',
        userid: '1009231',
        accesstime: '1724221301650',
        parentid: '303935382460956674',
        password: '**********',
        f_idnumber: '',
        f_create_date: '2024-04-18 16:54:12',
        selfid: '303936264133017601',
        logindate: '2024-09-29',
        templatename: 'useredit',
        id: '303936264133017602',
        state: '在职',
        tablename: 't_user',
        f_update_date: '2024-06-24 14:23:29',
        login_address: '内网IP',
        loginid: '15',
        imgid: 'null',
        f_user_telephone: '',
        rolestr: '阳春管理员,利川管理员,维修员,管理员,系统管理',
        loginnum: 1,
        f_age: '',
        resourcetype: 'user',
        f_organization_id: '303935212625199106',
        f_department_name: '客服中心',
        ename: 'ycgly',
        entitytype: 't_user',
        f_description: '',
        loginip: '10.233.70.0',
        f_ldap_version: 22,
        name: '阳春管理员',
        position: 1,
        haslicense: 'true',
        f_last_modification_time: '2024-06-24 14:22:54',
        forceoutstate: '1',
        f_role_name: '阳春管理员 利川管理员 维修员 管理员 系统管理'
      }
    ])

    const { runLogic } = require('@vue2-client/services/api/common')
    runLogic.mockResolvedValue(mockResponse)

   await searchToListOption(params, (res) => console.log(res))
  })
})

describe('获取分公司-列表', () => {
  it('should transform data correctly when response has nested children', async () => {
    const params = { source: '获取分公司', userid: '123' }
    const mockResponse = mockjs.mock([
      {
        hasright: false,
        resourcetype: 'root',
        entitytype: 't_root',
        children: [
          {
            parentname: '资源管理',
            f_icon: 'tree_org',
            hasright: false,
            f_companylevel: '',
            resourcetype: 'organization',
            parentid: '3',
            number: '1',
            entitytype: 't_organization',
            f_description: '根组织',
            children: [
              {
                f_update_date: '2024-10-16 17:04:20',
                loginid: '15',
                parentname: '组织机构',
                f_icon: 'tree_org',
                hasright: true,
                f_companylevel: '',
                resourcetype: 'organization',
                parentid: '9',
                number: '',
                entitytype: 't_organization',
                f_description: 'standard_windows   QBJYangChun',
                children: [
                  {
                    f_update_date: '2024-10-16 18:23:45',
                    loginid: '128028',
                    parentname: '铜川天然气有限公司',
                    f_serailport: '',
                    f_icon: 'tree_org',
                    hasright: true,
                    f_companylevel: '',
                    resourcetype: 'organization',
                    parentid: '37710',
                    entitytype: 't_organization',
                    f_description: '',
                    children: [],
                    f_create_date: '2024-10-16 18:23:20',
                    f_ldap_version: 3,
                    name: '测试222',
                    selfid: '369550898785026049',
                    templatename: 'organizationedit',
                    id: '369550898785026050',
                    position: 79,
                    fullname: '资源管理.组织机构.铜川天然气有限公司.测试222',
                    fullid: '3.9.37710.369550898785026050',
                    tablename: 't_organization',
                    f_dir: ''
                  }
                ],
                f_ldap_version: 181,
                name: '铜川天然气有限公司',
                selfid: '37711',
                templatename: 'organizationedit',
                id: '37710',
                position: 2,
                fullname: '资源管理.组织机构.铜川天然气有限公司',
                fullid: '3.9.37710',
                tablename: 't_organization',
                f_dir: 'standard'
              }
            ],
            f_ldap_version: 15,
            name: '组织机构',
            selfid: '10',
            templatename: 'organizationedit',
            id: '9',
            position: 1,
            fullname: '资源管理.组织机构',
            fullid: '3.9',
            tablename: 't_organization',
            f_dir: 'standard'
          }
        ],
        f_ldap_version: 6,
        selfid: '4',
        name: '资源管理',
        templatename: '根节点编辑模板',
        position: 1,
        id: '3',
        fullname: '资源管理',
        fullid: '3',
        tablename: 't_root'
      }
    ])

    const { runLogic } = require('@vue2-client/services/api/common')
    runLogic.mockResolvedValue(mockResponse)

   await searchToListOption(params, (res) => console.log(res))
  })
})
