2018-02-15 19:19:53 +03:00
|
|
|
<?php
|
|
|
|
namespace GraphQL\Tests\Utils;
|
|
|
|
|
|
|
|
use GraphQL\Executor\Values;
|
|
|
|
use GraphQL\Type\Definition\Type;
|
|
|
|
use GraphQL\Utils\Utils;
|
|
|
|
use GraphQL\Utils\Value;
|
2018-07-29 18:43:10 +03:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2018-02-15 19:19:53 +03:00
|
|
|
|
2018-07-29 18:43:10 +03:00
|
|
|
class SuggestionListTest extends TestCase
|
2018-02-15 19:19:53 +03:00
|
|
|
{
|
|
|
|
// DESCRIBE: suggestionList
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @it Returns results when input is empty
|
|
|
|
*/
|
|
|
|
public function testResturnsResultsWhenInputIsEmpty()
|
|
|
|
{
|
|
|
|
$this->assertEquals(
|
|
|
|
Utils::suggestionList('', ['a']),
|
|
|
|
['a']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @it Returns empty array when there are no options
|
|
|
|
*/
|
|
|
|
public function testReturnsEmptyArrayWhenThereAreNoOptions()
|
|
|
|
{
|
|
|
|
$this->assertEquals(
|
|
|
|
Utils::suggestionList('input', []),
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @it Returns options sorted based on similarity
|
|
|
|
*/
|
|
|
|
public function testReturnsOptionsSortedBasedOnSimilarity()
|
|
|
|
{
|
|
|
|
$this->assertEquals(
|
|
|
|
Utils::suggestionList('abc', ['a', 'ab', 'abc']),
|
|
|
|
['abc', 'ab']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|