Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
extract assertion method
Browse files Browse the repository at this point in the history
  • Loading branch information
adpinola committed Nov 17, 2022
1 parent 14b4098 commit 9c156fe
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ void main() {

group('#GetDirectoryPaths', () {
test('Should throw unimplemented exception', () async {
final FileSelectorPlatform sut = ExtendsFileSelectorPlatform();
final FileSelectorPlatform fileSelector = ExtendsFileSelectorPlatform();

await expectLater(() async {
return sut.getDirectoryPaths();
return fileSelector.getDirectoryPaths();
}, throwsA(isA<UnimplementedError>()));
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,49 +43,46 @@ void main() {
await plugin
.openFile(acceptedTypeGroups: <XTypeGroup>[group, groupTwo]);

expect(
expectMethodCall(
log,
<Matcher>[
isMethodCall('openFile', arguments: <String, dynamic>{
'acceptedTypeGroups': <Map<String, dynamic>>[
group.toJSON(),
groupTwo.toJSON()
],
'initialDirectory': null,
'confirmButtonText': null,
'multiple': false,
}),
],
'openFile',
arguments: <String, dynamic>{
'acceptedTypeGroups': <Map<String, dynamic>>[
group.toJSON(),
groupTwo.toJSON()
],
'initialDirectory': null,
'confirmButtonText': null,
'multiple': false,
},
);
});
test('passes initialDirectory correctly', () async {
await plugin.openFile(initialDirectory: '/example/directory');

expect(
expectMethodCall(
log,
<Matcher>[
isMethodCall('openFile', arguments: <String, dynamic>{
'acceptedTypeGroups': null,
'initialDirectory': '/example/directory',
'confirmButtonText': null,
'multiple': false,
}),
],
'openFile',
arguments: <String, dynamic>{
'acceptedTypeGroups': null,
'initialDirectory': '/example/directory',
'confirmButtonText': null,
'multiple': false,
},
);
});
test('passes confirmButtonText correctly', () async {
await plugin.openFile(confirmButtonText: 'Open File');

expect(
expectMethodCall(
log,
<Matcher>[
isMethodCall('openFile', arguments: <String, dynamic>{
'acceptedTypeGroups': null,
'initialDirectory': null,
'confirmButtonText': 'Open File',
'multiple': false,
}),
],
'openFile',
arguments: <String, dynamic>{
'acceptedTypeGroups': null,
'initialDirectory': null,
'confirmButtonText': 'Open File',
'multiple': false,
},
);
});
});
Expand All @@ -108,49 +105,46 @@ void main() {
await plugin
.openFiles(acceptedTypeGroups: <XTypeGroup>[group, groupTwo]);

expect(
expectMethodCall(
log,
<Matcher>[
isMethodCall('openFile', arguments: <String, dynamic>{
'acceptedTypeGroups': <Map<String, dynamic>>[
group.toJSON(),
groupTwo.toJSON()
],
'initialDirectory': null,
'confirmButtonText': null,
'multiple': true,
}),
],
'openFile',
arguments: <String, dynamic>{
'acceptedTypeGroups': <Map<String, dynamic>>[
group.toJSON(),
groupTwo.toJSON()
],
'initialDirectory': null,
'confirmButtonText': null,
'multiple': true,
},
);
});
test('passes initialDirectory correctly', () async {
await plugin.openFiles(initialDirectory: '/example/directory');

expect(
expectMethodCall(
log,
<Matcher>[
isMethodCall('openFile', arguments: <String, dynamic>{
'acceptedTypeGroups': null,
'initialDirectory': '/example/directory',
'confirmButtonText': null,
'multiple': true,
}),
],
'openFile',
arguments: <String, dynamic>{
'acceptedTypeGroups': null,
'initialDirectory': '/example/directory',
'confirmButtonText': null,
'multiple': true,
},
);
});
test('passes confirmButtonText correctly', () async {
await plugin.openFiles(confirmButtonText: 'Open File');

expect(
expectMethodCall(
log,
<Matcher>[
isMethodCall('openFile', arguments: <String, dynamic>{
'acceptedTypeGroups': null,
'initialDirectory': null,
'confirmButtonText': 'Open File',
'multiple': true,
}),
],
'openFile',
arguments: <String, dynamic>{
'acceptedTypeGroups': null,
'initialDirectory': null,
'confirmButtonText': 'Open File',
'multiple': true,
},
);
});
});
Expand All @@ -174,108 +168,109 @@ void main() {
await plugin
.getSavePath(acceptedTypeGroups: <XTypeGroup>[group, groupTwo]);

expect(
expectMethodCall(
log,
<Matcher>[
isMethodCall('getSavePath', arguments: <String, dynamic>{
'acceptedTypeGroups': <Map<String, dynamic>>[
group.toJSON(),
groupTwo.toJSON()
],
'initialDirectory': null,
'suggestedName': null,
'confirmButtonText': null,
}),
],
'getSavePath',
arguments: <String, dynamic>{
'acceptedTypeGroups': <Map<String, dynamic>>[
group.toJSON(),
groupTwo.toJSON()
],
'initialDirectory': null,
'suggestedName': null,
'confirmButtonText': null,
},
);
});
test('passes initialDirectory correctly', () async {
await plugin.getSavePath(initialDirectory: '/example/directory');

expect(
expectMethodCall(
log,
<Matcher>[
isMethodCall('getSavePath', arguments: <String, dynamic>{
'acceptedTypeGroups': null,
'initialDirectory': '/example/directory',
'suggestedName': null,
'confirmButtonText': null,
}),
],
'getSavePath',
arguments: <String, dynamic>{
'acceptedTypeGroups': null,
'initialDirectory': '/example/directory',
'suggestedName': null,
'confirmButtonText': null,
},
);
});
test('passes confirmButtonText correctly', () async {
await plugin.getSavePath(confirmButtonText: 'Open File');

expect(
expectMethodCall(
log,
<Matcher>[
isMethodCall('getSavePath', arguments: <String, dynamic>{
'acceptedTypeGroups': null,
'initialDirectory': null,
'suggestedName': null,
'confirmButtonText': 'Open File',
}),
],
'getSavePath',
arguments: <String, dynamic>{
'acceptedTypeGroups': null,
'initialDirectory': null,
'suggestedName': null,
'confirmButtonText': 'Open File',
},
);
});
});
group('#getDirectoryPath', () {
test('passes initialDirectory correctly', () async {
await plugin.getDirectoryPath(initialDirectory: '/example/directory');

expect(
expectMethodCall(
log,
<Matcher>[
isMethodCall('getDirectoryPath', arguments: <String, dynamic>{
'initialDirectory': '/example/directory',
'confirmButtonText': null,
}),
],
'getDirectoryPath',
arguments: <String, dynamic>{
'initialDirectory': '/example/directory',
'confirmButtonText': null,
},
);
});
test('passes confirmButtonText correctly', () async {
await plugin.getDirectoryPath(confirmButtonText: 'Select Folder');

expect(
expectMethodCall(
log,
<Matcher>[
isMethodCall('getDirectoryPath', arguments: <String, dynamic>{
'initialDirectory': null,
'confirmButtonText': 'Select Folder',
}),
],
'getDirectoryPath',
arguments: <String, dynamic>{
'initialDirectory': null,
'confirmButtonText': 'Select Folder',
},
);
});
});
group('#getDirectoryPaths', () {
test('passes initialDirectory correctly', () async {
await plugin.getDirectoryPaths(initialDirectory: '/example/directory');

expect(
expectMethodCall(
log,
<Matcher>[
isMethodCall('getDirectoryPaths', arguments: <String, dynamic>{
'initialDirectory': '/example/directory',
'confirmButtonText': null,
}),
],
'getDirectoryPaths',
arguments: <String, dynamic>{
'initialDirectory': '/example/directory',
'confirmButtonText': null,
},
);
});
test('passes confirmButtonText correctly', () async {
await plugin.getDirectoryPaths(
confirmButtonText: 'Select one or more Folders');

expect(
expectMethodCall(
log,
<Matcher>[
isMethodCall('getDirectoryPaths', arguments: <String, dynamic>{
'initialDirectory': null,
'confirmButtonText': 'Select one or more Folders',
}),
],
'getDirectoryPaths',
arguments: <String, dynamic>{
'initialDirectory': null,
'confirmButtonText': 'Select one or more Folders',
},
);
});
});
});
}

void expectMethodCall(
List<MethodCall> log,
String methodName, {
Map<String, dynamic>? arguments,
}) {
expect(log, <Matcher>[isMethodCall(methodName, arguments: arguments)]);
}

0 comments on commit 9c156fe

Please sign in to comment.