Skip to content

Commit

Permalink
Revert "Stop rejecting on dismissAllModals if no modals are displayed (
Browse files Browse the repository at this point in the history
…wix#5991)"

This reverts commit 9754281.
  • Loading branch information
pawlitos authored Apr 8, 2020
1 parent f74e8ce commit 0f96c65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ 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.BaseTest;
import com.reactnativenavigation.TestUtils;
import com.reactnativenavigation.*;
import com.reactnativenavigation.anim.ModalAnimator;
import com.reactnativenavigation.mocks.SimpleViewController;
import com.reactnativenavigation.parse.Options;
Expand All @@ -14,15 +14,13 @@
import com.reactnativenavigation.utils.CommandListenerAdapter;
import com.reactnativenavigation.viewcontrollers.ChildControllersRegistry;
import com.reactnativenavigation.viewcontrollers.ViewController;
import com.reactnativenavigation.viewcontrollers.stack.StackController;
import com.reactnativenavigation.viewcontrollers.stack.*;

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 @@ -173,6 +171,13 @@ 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 0f96c65

Please sign in to comment.