TF-2177 Update account cache when store new account

Signed-off-by: dab246 <tdvu@linagora.com>
(cherry picked from commit 3fff318bbe66a5f4387c25d18e0d2a9480719d72)
This commit is contained in:
dab246
2023-10-24 14:08:54 +07:00
committed by Dat H. Pham
parent 6a0b3a7bc4
commit fc4a4792c3
4 changed files with 109 additions and 6 deletions
@@ -0,0 +1,46 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:tmail_ui_user/features/login/data/extensions/list_account_cache_extensions.dart';
import 'package:tmail_ui_user/features/login/data/model/account_cache.dart';
void main() {
group('AccountCache test', () {
test('removeDuplicated should remove duplicate accountId', () async {
final account1 = AccountCache(
'1',
'oidc',
isSelected: true,
accountId: '1',
userName: '1',
apiUrl: 'https://example.com/jmap'
);
final account2 = AccountCache(
'2',
'oidc',
isSelected: true,
accountId: '1',
userName: '1',
apiUrl: 'https://example.com/jmap'
);
final account3 = AccountCache(
'3',
'basic',
isSelected: true,
accountId: '2',
userName: '2',
apiUrl: 'https://example.com/jmap'
);
final account4 = AccountCache(
'4',
'basic',
isSelected: true,
accountId: '2',
userName: '2',
apiUrl: 'https://example.com/jmap'
);
final result = [account1, account2, account3, account4].removeDuplicated();
expect(result, equals([account1, account3]));
});
});
}