I have a function similar to this one below:
Future<void> saveFile ({
required String fileName,
required Uint8List bytes,
bool permanent = true,
) async {
final directory = permanent ? 'permanentFolder' : 'tempFolder';
final filePath = join(directory, fileName);
final file = File(filePath);
await file.create(recursive: true);
await file.writeAsBytes(bytes);
}
I want to write a test on it that verifies that the method join from package:path/path.dart is being called with the right parameters.
await saveFile(fileName: 'name', bytes: []);
verify(() => join('permanentFolder', 'name')).called(1);
await saveFile(fileName: 'name', bytes: [], permanent: false);
verify(() => join('tempFolder', 'name')).called(1);
I have not been successful in mocking the join function in order for this test to pass.