-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathScoringTest.php
More file actions
34 lines (26 loc) · 1.02 KB
/
ScoringTest.php
File metadata and controls
34 lines (26 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
declare(strict_types=1);
use Fuse\Fuse;
beforeEach(function () {
$this->defaultList = ['Stove', 'My good friend Steve from college'];
$this->defaultOptions = [];
$this->setupFuse = function ($itemList = null, $overwriteOptions = []) {
$list = $itemList ?? $this->defaultList;
$options = array_merge($this->defaultOptions, $overwriteOptions);
return new Fuse($list, $options);
};
});
it('should return the correct indices when field norm is off', function () {
$fuse = ($this->setupFuse)();
$result = $fuse->search('Steve');
expect($result)->toHaveCount(2);
expect($result[0]['refIndex'])->toBe(0);
expect($result[1]['refIndex'])->toBe(1);
});
it('should return the correct indices when field norm weight is decreased', function () {
$fuse = ($this->setupFuse)(null, ['fieldNormWeight' => 0.15]);
$result = $fuse->search('Steve');
expect($result)->toHaveCount(2);
expect($result[0]['refIndex'])->toBe(1);
expect($result[1]['refIndex'])->toBe(0);
});