Sha256: 2c708c557c9595219b1a281935f025b8e6141b6d966f6159b505f4a85a8f0196

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

require 'spec_helper'

describe NetSuite::Support::SearchResult do
  before(:all) { savon.mock! }
  after(:all) { savon.unmock! }

  describe '#results' do
    context 'empty page' do
      it 'returns empty array' do
        response_body = {
          :status => {:@is_success=>"true"},
          :total_records => "242258",
          :page_size => "10",
          :total_pages => "24226",
          :page_index => "99",
          :search_id => "WEBSERVICES_4132604_SB1_051620191060155623420663266_336cbf12",
          :record_list => nil,
          :"@xmlns:platform_core" => "urn:core_2016_2.platform.webservices.netsuite.com"
        }
        response = NetSuite::Response.new(body: response_body)

        results = described_class.new(response, NetSuite::Actions::Search, {}).results
        expect(results).to eq []
      end

      it 'returns empty search_row_list' do
        response_body = {
          :status => {:@is_success=>"true"},
          :total_records => "242258",
          :page_size => "10",
          :total_pages => "24226",
          :page_index => "99",
          :search_id => "WEBSERVICES_4132604_SB1_051620191060155623420663266_336cbf12",
          :search_row_list => nil,
          :"@xmlns:platform_core" => "urn:core_2016_2.platform.webservices.netsuite.com"
        }
        response = NetSuite::Response.new(body: response_body)

        results = described_class.new(response, NetSuite::Actions::Search, {}).results
        expect(results).to eq []
      end
    end

    it 'handles a recordList with a single element' do
      response = File.read('spec/support/fixtures/search/single_search_result.xml')
      savon.expects(:search).with(message: {}).returns(response)

      results = NetSuite::Records::Account.search(basic: [])

      expect(results.results.count).to eq 1
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
netsuite-0.9.3 spec/netsuite/support/search_result_spec.rb