|
13 | 13 | before { index.add_documents!(document) } |
14 | 14 |
|
15 | 15 | it 'searches with default cropping params' do |
16 | | - response = index.search('galaxy', attributesToCrop: ['*'], cropLength: 6) |
| 16 | + response = index.search('galaxy', attributes_to_crop: ['*'], crop_length: 6) |
17 | 17 |
|
18 | 18 | expect(response.dig('hits', 0, '_formatted', 'description')).to eq('…Guide to the Galaxy is a…') |
19 | 19 | end |
20 | 20 |
|
21 | 21 | it 'searches with custom crop markers' do |
22 | | - response = index.search('galaxy', attributesToCrop: ['*'], cropLength: 6, cropMarker: '(ꈍᴗꈍ)') |
| 22 | + response = index.search('galaxy', attributes_to_crop: ['*'], crop_length: 6, crop_marker: '(ꈍᴗꈍ)') |
23 | 23 |
|
24 | 24 | expect(response.dig('hits', 0, '_formatted', 'description')).to eq('(ꈍᴗꈍ)Guide to the Galaxy is a(ꈍᴗꈍ)') |
25 | 25 | end |
26 | 26 |
|
27 | 27 | it 'searches with mixed highlight and crop config' do |
28 | 28 | response = index.search( |
29 | 29 | 'galaxy', |
30 | | - attributesToHighlight: ['*'], |
31 | | - attributesToCrop: ['*'], |
32 | | - highlightPreTag: '<span class="bold">' |
| 30 | + attributes_to_highlight: ['*'], |
| 31 | + attributes_to_crop: ['*'], |
| 32 | + highlight_pre_tag: '<span class="bold">' |
33 | 33 | ) |
34 | 34 |
|
35 | 35 | expect(response.dig('hits', 0, '_formatted', 'description')).to \ |
|
39 | 39 | it 'searches with highlight tags' do |
40 | 40 | response = index.search( |
41 | 41 | 'galaxy', |
42 | | - attributesToHighlight: ['*'], |
43 | | - highlightPreTag: '<span>', |
44 | | - highlightPostTag: '</span>' |
| 42 | + attributes_to_highlight: ['*'], |
| 43 | + highlight_pre_tag: '<span>', |
| 44 | + highlight_post_tag: '</span>' |
45 | 45 | ) |
46 | 46 |
|
47 | 47 | expect(response.dig('hits', 0, '_formatted', 'description')).to include('<span>Galaxy</span>') |
48 | 48 | end |
49 | 49 |
|
50 | 50 | it 'does a custom search with attributes to crop' do |
51 | | - response = index.search('galaxy', { attributesToCrop: ['description'], cropLength: 6 }) |
| 51 | + response = index.search('galaxy', { attributes_to_crop: ['description'], crop_length: 6 }) |
52 | 52 | expect(response['hits'].first).to have_key('_formatted') |
53 | 53 | expect(response['hits'].first['_formatted']['description']).to eq('…Guide to the Galaxy is a…') |
54 | 54 | end |
55 | 55 |
|
56 | 56 | it 'does a placehodler search with attributes to crop' do |
57 | | - response = index.search('', { attributesToCrop: ['description'], cropLength: 5 }) |
| 57 | + response = index.search('', { attributes_to_crop: ['description'], crop_length: 5 }) |
58 | 58 | expect(response['hits'].first).to have_key('_formatted') |
59 | 59 | expect(response['hits'].first['description']).to eq(document[:description]) |
60 | 60 | expect(response['hits'].first['_formatted']['description']).to eq("The Hitchhiker's Guide to…") |
|
0 commit comments