-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test ensuring our space search works find
- Loading branch information
Showing
2 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import 'package:acter/common/providers/room_providers.dart'; | ||
import 'package:acter/common/providers/space_providers.dart'; | ||
import 'package:acter/features/search/providers/quick_search_providers.dart'; | ||
import 'package:acter/features/spaces/providers/space_list_provider.dart'; | ||
import 'package:acter_avatar/acter_avatar.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import '../../helpers/mock_space_providers.dart'; | ||
|
||
void main() { | ||
group('Spaces Search Provider Test', () { | ||
test( | ||
'Display Name update triggers proper update of search values on quick search', | ||
() async { | ||
final spaces = [ | ||
MockSpace(id: 'a'), | ||
MockSpace(id: 'b'), | ||
MockSpace(id: 'c'), | ||
]; | ||
final Map<String, AvatarInfo> spaceInfos = { | ||
'a': const AvatarInfo(uniqueId: 'a', displayName: 'abc'), | ||
'b': const AvatarInfo( | ||
uniqueId: 'b', | ||
displayName: null, | ||
), // not yet loaded | ||
'c': const AvatarInfo(uniqueId: 'c', displayName: null), | ||
}; | ||
final container = ProviderContainer( | ||
overrides: [ | ||
spacesProvider.overrideWith((a) => MockSpaceListNotifiers(spaces)), | ||
roomAvatarInfoProvider.overrideWith( | ||
() => MockRoomAvatarInfoNotifier(items: spaceInfos), | ||
), | ||
bookmarkedSpacesProvider.overrideWith((a) => []), | ||
], | ||
); | ||
|
||
final all = container.read(spaceListQuickSearchedProvider); | ||
expect(all.length, 3); | ||
|
||
// add a search term | ||
container.read(quickSearchValueProvider.notifier).state = 'a'; | ||
|
||
final onlyOne = container.read(spaceListQuickSearchedProvider); | ||
expect(onlyOne.length, 1); | ||
|
||
// update a space info | ||
spaceInfos['b'] = const AvatarInfo(uniqueId: 'b', displayName: 'abc'); | ||
// we only refresh the inner provider | ||
container.refresh(roomAvatarInfoProvider('b')); | ||
|
||
final itsTwo = container.read(spaceListQuickSearchedProvider); | ||
expect(itsTwo.length, 2); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters