# frozen_string_literal: true

require 'spec_helper'
require_relative '../../lib/task_info_converter'

RSpec.describe TaskInfoConverter do
  let(:input_data) do
    {
      "Cisco Catalyst 2960" => {
        "devs" => [{
          "id" => "4a891589-ebe9-4914-8b39-1bb928dfc7ac",
          "name" => "测试交换机",
          "device_type" => "switch",
          "device_model" => "Cisco Catalyst 2960",
          "description" => "测试用网络交换机"
        }],
        "scripts" => [{
          "id" => 25,
          "name" => "测试4",
          "device_types" => [],
          "device_models" => ["Cisco Catalyst 2960"],
          "description" => "该脚"
        }]
      }
    }
  end

  it '转换按型号分组的格式为标准格式' do
    converted = described_class.convert(input_data)
    
    expect(converted[:devices].size).to eq(1)
    expect(converted[:scripts].size).to eq(1)
    expect(converted[:devices][0]['name']).to eq('测试交换机')
    expect(converted[:scripts][0]['name']).to eq('测试4')
  end
end
