Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
frankmer committed Jul 12, 2024
1 parent 5a03ee3 commit 2909bab
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/unit_test/state_notifiers/sortable_notifier_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:privacyidea_authenticator/model/enums/algorithms.dart';
import 'package:privacyidea_authenticator/model/states/settings_state.dart';
import 'package:privacyidea_authenticator/model/token_folder.dart';
import 'package:privacyidea_authenticator/model/tokens/hotp_token.dart';
import 'package:privacyidea_authenticator/model/tokens/token.dart';
import 'package:privacyidea_authenticator/model/tokens/totp_token.dart';
import 'package:privacyidea_authenticator/state_notifiers/settings_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/sortable_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_folder_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_notifier.dart';
Expand All @@ -20,6 +22,8 @@ void main() {
void _testSortableNotifier() {
group('SortableNotifier test', () {
test('handleNewList', () async {
final mockSettingsRepo = MockSettingsRepository();
when(mockSettingsRepo.loadSettings()).thenAnswer((_) async => SettingsState());
final MockTokenFolderRepository mockTokenFolderRepository = MockTokenFolderRepository();
final MockTokenRepository mockTokenRepository = MockTokenRepository();
List<TokenFolder> tokenFolderState = [
Expand Down Expand Up @@ -51,6 +55,7 @@ void _testSortableNotifier() {
});

final container = ProviderContainer(overrides: [
settingsProvider.overrideWith((ref) => SettingsNotifier(repository: mockSettingsRepo)),
tokenFolderProvider.overrideWith((ref) => TokenFolderNotifier(repository: mockTokenFolderRepository)),
tokenProvider.overrideWith((ref) => TokenNotifier(repository: mockTokenRepository, ref: ref)),
]);
Expand All @@ -63,8 +68,6 @@ void _testSortableNotifier() {
final newState = await sortableNotifier.handleNewStateList(newTokenState);

final newSortableState = container.read(sortableProvider);
print('newSortableState: $newSortableState');
print('newState: $newState');
expect(newState.length, 6);
expect(newSortableState.length, 6);
expect(newSortableState[0], isA<Token>());
Expand Down

0 comments on commit 2909bab

Please sign in to comment.