mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-25 14:26:08 +03:00
47 lines
1.0 KiB
PHP
47 lines
1.0 KiB
PHP
<?php
|
|
namespace GraphQL\Tests\Utils;
|
|
|
|
use GraphQL\Executor\Values;
|
|
use GraphQL\Type\Definition\Type;
|
|
use GraphQL\Utils\Utils;
|
|
use GraphQL\Utils\Value;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class SuggestionListTest extends TestCase
|
|
{
|
|
// 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']
|
|
);
|
|
}
|
|
}
|