diff --git a/test/bloc/ls_dir_test.dart b/test/bloc/ls_dir_test.dart index 9fc4458c..1f922a5b 100644 --- a/test/bloc/ls_dir_test.dart +++ b/test/bloc/ls_dir_test.dart @@ -1,13 +1,12 @@ -import 'dart:typed_data'; - import 'package:bloc_test/bloc_test.dart'; import 'package:nc_photos/account.dart'; import 'package:nc_photos/bloc/ls_dir.dart'; import 'package:nc_photos/entity/file.dart'; -import 'package:nc_photos/or_null.dart'; import 'package:path/path.dart' as path; import 'package:test/test.dart'; +import '../mock_type.dart'; + void main() { final _buildBloc = () => LsDirBloc(fileRepo: _MockFileRepo()); final _buildAccount = @@ -130,29 +129,9 @@ void main() { }); } -class _MockFileRepo implements FileRepo { +class _MockFileRepo extends MockFileRepo { @override - Future copy(Object account, File f, String destination, - {bool? shouldOverwrite}) { - throw UnimplementedError(); - } - - @override - Future createDir(Account account, String path) { - throw UnimplementedError(); - } - - @override - FileDataSource get dataSrc => throw UnimplementedError(); - - @override - Future getBinary(Account account, File file) { - throw UnimplementedError(); - } - - @override - Future> list(Account account, File root) async { - await Future.delayed(const Duration(seconds: 1)); + list(Account account, File root) async { return [ File( path: "remote.php/dav/files/admin/test1.jpg", @@ -178,28 +157,4 @@ class _MockFileRepo implements FileRepo { ), ].where((element) => path.dirname(element.path) == root.path).toList(); } - - @override - Future move(Account account, File f, String destination, - {bool? shouldOverwrite}) { - throw UnimplementedError(); - } - - @override - Future putBinary(Account account, String path, Uint8List content) { - throw UnimplementedError(); - } - - @override - Future remove(Account account, File file) { - throw UnimplementedError(); - } - - @override - Future updateProperty(Account account, File file, - {OrNull? metadata, - OrNull? isArchived, - OrNull? overrideDateTime}) { - throw UnimplementedError(); - } } diff --git a/test/mock_type.dart b/test/mock_type.dart new file mode 100644 index 00000000..e74a560d --- /dev/null +++ b/test/mock_type.dart @@ -0,0 +1,56 @@ +import 'dart:typed_data'; + +import 'package:nc_photos/account.dart'; +import 'package:nc_photos/entity/file.dart'; +import 'package:nc_photos/or_null.dart'; + +/// Mock of [FileRepo] where all methods will throw UnimplementedError +class MockFileRepo implements FileRepo { + @override + Future copy(Object account, File f, String destination, + {bool? shouldOverwrite}) { + throw UnimplementedError(); + } + + @override + Future createDir(Account account, String path) { + throw UnimplementedError(); + } + + @override + FileDataSource get dataSrc => throw UnimplementedError(); + + @override + Future getBinary(Account account, File file) { + throw UnimplementedError(); + } + + @override + Future> list(Account account, File root) async { + throw UnimplementedError(); + } + + @override + Future move(Account account, File f, String destination, + {bool? shouldOverwrite}) { + throw UnimplementedError(); + } + + @override + Future putBinary(Account account, String path, Uint8List content) { + throw UnimplementedError(); + } + + @override + Future remove(Account account, File file) { + throw UnimplementedError(); + } + + @override + Future updateProperty(Account account, File file, + {OrNull? metadata, + OrNull? isArchived, + OrNull? overrideDateTime}) { + throw UnimplementedError(); + } +}