PublicAsset empty check before calling destroy on discard identity
This commit is contained in:
@@ -187,7 +187,7 @@ class PublicAssetController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void discardChanges() {
|
void discardChanges() {
|
||||||
if (session == null || accountId == null) return;
|
if (session == null || accountId == null || newlyPickedPublicAssetIds.isEmpty) return;
|
||||||
consumeState(_deletePublicAssetsInteractor.execute(
|
consumeState(_deletePublicAssetsInteractor.execute(
|
||||||
session!,
|
session!,
|
||||||
accountId!,
|
accountId!,
|
||||||
|
|||||||
@@ -161,7 +161,47 @@ void main() {
|
|||||||
group("IdentityCreatorController test:", () {
|
group("IdentityCreatorController test:", () {
|
||||||
test(
|
test(
|
||||||
'should call deletePublicAssetsInteractor.execute() '
|
'should call deletePublicAssetsInteractor.execute() '
|
||||||
'when closeView() is called',
|
'when closeView() is called '
|
||||||
|
'and user has picked at lease one image',
|
||||||
|
() {
|
||||||
|
// arrange
|
||||||
|
final accountId = AccountId(Id('value'));
|
||||||
|
final account = Account(
|
||||||
|
AccountName('value'),
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
{CapabilityIdentifier.jmapPublicAsset: DefaultCapability({})});
|
||||||
|
final session = Session(
|
||||||
|
{},
|
||||||
|
{accountId: account},
|
||||||
|
{}, UserName('value'), Uri(), Uri(), Uri(), Uri(), State('value'));
|
||||||
|
identityCreatorController.arguments = IdentityCreatorArguments(accountId, session);
|
||||||
|
|
||||||
|
// act
|
||||||
|
identityCreatorController.onReady();
|
||||||
|
expect(identityCreatorController.publicAssetController, isNotNull);
|
||||||
|
identityCreatorController.publicAssetController?.newlyPickedPublicAssetIds.add(Id('value'));
|
||||||
|
|
||||||
|
final context = MockBuildContext();
|
||||||
|
final buildOwner = MockBuildOwner();
|
||||||
|
final focusManager = MockFocusManager();
|
||||||
|
when(context.owner).thenReturn(buildOwner);
|
||||||
|
when(buildOwner.focusManager).thenReturn(focusManager);
|
||||||
|
when(focusManager.rootScope).thenReturn(FocusScopeNode());
|
||||||
|
identityCreatorController.closeView(context);
|
||||||
|
|
||||||
|
// assert
|
||||||
|
verify(deletePublicAssetsInteractor.execute(
|
||||||
|
session,
|
||||||
|
accountId,
|
||||||
|
publicAssetIds: anyNamed('publicAssetIds'),
|
||||||
|
)).called(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'should not call deletePublicAssetsInteractor.execute() '
|
||||||
|
'when closeView() is called '
|
||||||
|
'and user has not picked any image',
|
||||||
() {
|
() {
|
||||||
// arrange
|
// arrange
|
||||||
final accountId = AccountId(Id('value'));
|
final accountId = AccountId(Id('value'));
|
||||||
@@ -189,11 +229,11 @@ void main() {
|
|||||||
identityCreatorController.closeView(context);
|
identityCreatorController.closeView(context);
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
verify(deletePublicAssetsInteractor.execute(
|
verifyNever(deletePublicAssetsInteractor.execute(
|
||||||
session,
|
session,
|
||||||
accountId,
|
accountId,
|
||||||
publicAssetIds: anyNamed('publicAssetIds'),
|
publicAssetIds: anyNamed('publicAssetIds'),
|
||||||
)).called(1);
|
));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user