Skip to content

Commit

Permalink
Stop rejecting on dismissAllModals if no modals are displayed (#5991)
Browse files Browse the repository at this point in the history
This commit adds parity with iOS which does not reject the promise if dismissAllModals is called while no modals are displayed.
  • Loading branch information
guyca authored Mar 3, 2020
1 parent fa69b8f commit 30b0b47
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@ public void onSuccess(String childId) {

public void dismissAllModals(ViewController root, Options mergeOptions, CommandListener listener) {
if (modals.isEmpty()) {
listener.onError("Nothing to dismiss");
return;
}

String topModalId = peek().getId();
String topModalName = peek().getCurrentComponentName();
int modalsDismissed = size();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.reactnativenavigation.viewcontrollers.modal;

import android.app.Activity;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.reactnativenavigation.*;
import com.reactnativenavigation.BaseTest;
import com.reactnativenavigation.TestUtils;
import com.reactnativenavigation.anim.ModalAnimator;
import com.reactnativenavigation.mocks.SimpleViewController;
import com.reactnativenavigation.parse.Options;
Expand All @@ -14,13 +14,15 @@
import com.reactnativenavigation.utils.CommandListenerAdapter;
import com.reactnativenavigation.viewcontrollers.ChildControllersRegistry;
import com.reactnativenavigation.viewcontrollers.ViewController;
import com.reactnativenavigation.viewcontrollers.stack.*;
import com.reactnativenavigation.viewcontrollers.stack.StackController;

import org.junit.Test;
import org.mockito.Mockito;

import java.util.EmptyStackException;

import androidx.coordinatorlayout.widget.CoordinatorLayout;

import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.assertj.core.api.Java6Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
Expand Down Expand Up @@ -171,13 +173,6 @@ public void onSuccess(String childId) {
verifyZeroInteractions(listener);
}

@Test
public void dismissAllModals_rejectIfEmpty() {
CommandListener spy = spy(new CommandListenerAdapter());
uut.dismissAllModals(root, Options.EMPTY, spy);
verify(spy, times(1)).onError(any());
}

@Test
public void dismissAllModals_optionsAreMergedOnTopModal() {
uut.showModal(modal1, root, new CommandListenerAdapter());
Expand Down

0 comments on commit 30b0b47

Please sign in to comment.