Skip to content

Commit 790743f

Browse files
committed
review comments
1 parent c5a593a commit 790743f

1 file changed

Lines changed: 23 additions & 20 deletions

File tree

packages/devtools_app/test/shared/ui/search_test.dart

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import 'package:devtools_app/devtools_app.dart';
66
import 'package:devtools_app_shared/utils.dart';
77
import 'package:flutter/material.dart';
8+
import 'package:fake_async/fake_async.dart';
89
import 'package:flutter_test/flutter_test.dart';
910

1011
void main() {
@@ -120,24 +121,26 @@ void main() {
120121
}
121122
});
122123

123-
test('debounce', () async {
124-
final debounceController = TestDebounceSearchController()
125-
..data.addAll(testData);
126-
expect(debounceController.search, isEmpty);
127-
expect(debounceController.searchMatches.value, isEmpty);
128-
129-
debounceController.search = 'foo';
130-
expect(debounceController.search, equals('foo'));
131-
expect(
132-
debounceController.searchMatches.value,
133-
isEmpty,
134-
); // Has not updated yet
135-
expect(debounceController.isSearchInProgress, isTrue);
136-
137-
await Future.delayed(const Duration(milliseconds: 150));
138-
139-
expect(debounceController.isSearchInProgress, isFalse);
140-
expect(debounceController.searchMatches.value.length, equals(3));
124+
test('debounce', () {
125+
fakeAsync((async) {
126+
final debounceController = TestDebounceSearchController()
127+
..data.addAll(testData);
128+
expect(debounceController.search, isEmpty);
129+
expect(debounceController.searchMatches.value, isEmpty);
130+
131+
debounceController.search = 'foo';
132+
expect(debounceController.search, equals('foo'));
133+
expect(
134+
debounceController.searchMatches.value,
135+
isEmpty,
136+
); // Has not updated yet
137+
expect(debounceController.isSearchInProgress, isTrue);
138+
139+
async.elapse(const Duration(milliseconds: 150));
140+
141+
expect(debounceController.isSearchInProgress, isFalse);
142+
expect(debounceController.searchMatches.value.length, equals(3));
143+
});
141144
});
142145
});
143146

@@ -365,7 +368,7 @@ class TestSearchData with SearchableDataMixin {
365368

366369
@override
367370
bool matchesSearchToken(RegExp regExpSearch) {
368-
return name.caseInsensitiveContains(regExpSearch.pattern);
371+
return regExpSearch.hasMatch(name);
369372
}
370373
}
371374

@@ -376,7 +379,7 @@ class TestAutoCompleteSearchController extends DisposableController
376379
}
377380

378381
@override
379-
GlobalKey<State<StatefulWidget>> get searchFieldKey => GlobalKey();
382+
final searchFieldKey = GlobalKey();
380383

381384
@override
382385
Iterable<SearchableDataMixin> get currentDataToSearchThrough => [];

0 commit comments

Comments
 (0)