55import 'package:devtools_app/devtools_app.dart' ;
66import 'package:devtools_app_shared/utils.dart' ;
77import 'package:flutter/material.dart' ;
8+ import 'package:fake_async/fake_async.dart' ;
89import 'package:flutter_test/flutter_test.dart' ;
910
1011void 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