This commit is contained in:
@@ -246,12 +246,12 @@ Future<List<ScoredEntryId>> fetchEntryIds(
|
||||
int? pageSize,
|
||||
int? offset,
|
||||
) async {
|
||||
assert(word.trim().isNotEmpty, 'Word should not be empty when fetching entry IDs');
|
||||
|
||||
if (searchMode == SearchMode.auto) {
|
||||
searchMode = _determineSearchMode(word);
|
||||
}
|
||||
|
||||
assert(word.isNotEmpty, 'Word should not be empty when fetching entry IDs');
|
||||
|
||||
late final List<ScoredEntryId> entryIds;
|
||||
switch (searchMode) {
|
||||
case SearchMode.kanji:
|
||||
|
||||
@@ -41,7 +41,7 @@ Future<List<WordSearchResult>?> searchWordWithDbConnection(
|
||||
int page = 0,
|
||||
int? pageSize,
|
||||
}) async {
|
||||
if (word.isEmpty) {
|
||||
if (word.trim().isEmpty) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,22 @@ import 'package:test/test.dart';
|
||||
import 'setup_database_connection.dart';
|
||||
|
||||
void main() {
|
||||
test('Search empty string - auto', () async {
|
||||
final connection = await setupDatabaseConnection();
|
||||
final result = await connection.jadbSearchWord('');
|
||||
expect(result, isNull);
|
||||
});
|
||||
|
||||
test('Search whitespace - auto', () async {
|
||||
final connection = await setupDatabaseConnection();
|
||||
final result1 = await connection.jadbSearchWord(' ');
|
||||
expect(result1, isNull);
|
||||
final result2 = await connection.jadbSearchWord('\t');
|
||||
expect(result2, isNull);
|
||||
final result3 = await connection.jadbSearchWord('\n');
|
||||
expect(result3, isNull);
|
||||
});
|
||||
|
||||
test('Search a word - english - auto', () async {
|
||||
final connection = await setupDatabaseConnection();
|
||||
final result = await connection.jadbSearchWord('kana');
|
||||
|
||||
Reference in New Issue
Block a user