require 'rails_helper'
require 'lib/import/factory_examples'
require 'lib/import/otrs/dynamic_field_examples'

RSpec.describe Import::OTRS::DynamicFieldFactory do
  it_behaves_like 'Import::Factory'

  let(:start_import_test) { described_class.import(object_structure) }
  let(:object_structure) { [load_dynamic_field_json('text/default')] }

  it 'responds to skip_field?' do
    expect(described_class).to respond_to('skip_field?')
  end

  it 'skips fields that have unsupported types' do
    described_class.import([load_dynamic_field_json('unsupported/master_slave')])
    expect(described_class.skip_field?('MasterSlave')).to be true
  end

  it 'imports OTRS DynamicFields' do
    expect(Import::OTRS::DynamicField::Text).to receive(:new)
    start_import_test
  end
end
