todo-app/test/attachments/image_password_store_test.dart
Krzysztof kuhy Rudnicki 0798f7b1d0 Attach images to notes, stored on dufs and kept offline
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-25 14:11:15 +02:00

28 lines
906 B
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:todo/attachments/image_password_store.dart';
import '../fake_secure_storage.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
const store = ImagePasswordStore();
test('write, read, login and delete', () async {
installFakeSecureStorage();
expect(await store.read(), '');
expect(await store.login(), isNull);
expect(await store.write('pw'), isTrue);
expect(await store.read(), 'pw');
final login = (await store.login())!;
expect((login.user, login.password), (kDufsImagesUser, 'pw'));
expect(await store.write(''), isTrue);
expect(await store.read(), '');
});
test('a missing keystore reads as no password and refuses writes', () async {
installFakeSecureStorage(throwing: true);
expect(await store.read(), '');
expect(await store.write('pw'), isFalse);
});
}