Sha256: 0b117a9d1eca08b1bb1f7fd2b45f20ab29edb13ccc6e5878b1bd2b8ae8e9d1ad

Contents?: true

Size: 1.45 KB

Versions: 7

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

RSpec.describe Blacklight::Suggest::Response, :api do
  let(:empty_response) { described_class.new({}, { q: 'hello' }, 'suggest', 'mySuggester') }
  let(:full_response) do
    described_class.new(
      {
        'responseHeader' => {
          'status' => 200
        },
        'suggest' => {
          'mySuggester' => {
            'new' => {
              'numFound' => 3,
              'suggestions' => [
                {
                  'term' => 'new jersey',
                  'weight' => 3,
                  'payload' => ''
                },
                {
                  'term' => 'new jersey bridgeton biography',
                  'weight' => 3,
                  'payload' => ''
                },
                {
                  'term' => 'new jersey bridgeton history',
                  'weight' => 3,
                  'payload' => ''
                }
              ]
            }
          }
        }
      },
      {
        q: 'new'
      },
      'suggest',
      'mySuggester'
    )
  end

  describe '#initialize' do
    it 'creates a Blacklight::Suggest::Response' do
      expect(empty_response).to be_an described_class
    end
  end

  describe '#suggestions' do
    it 'returns an array of suggestions' do
      expect(full_response.suggestions).to be_an Array
      expect(full_response.suggestions.count).to eq 3
      expect(full_response.suggestions.first['term']).to eq 'new jersey'
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
blacklight-8.6.1 spec/models/blacklight/suggest/response_spec.rb
blacklight-8.6.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-8.5.1 spec/models/blacklight/suggest/response_spec.rb
blacklight-8.5.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-8.4.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/spec/models/blacklight/suggest/response_spec.rb
blacklight-8.3.0 spec/models/blacklight/suggest/response_spec.rb