Skip to content

Commit

Permalink
Always resolve dismissAllModals promise (#6054)
Browse files Browse the repository at this point in the history
When no modals are displayed and dismissAllModals is called, resolve the promise successfully. This regression was introduced in #5991
  • Loading branch information
guyca authored Mar 18, 2020
1 parent 6046372 commit ec03383
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public void onSuccess(String childId) {

public void dismissAllModals(ViewController root, Options mergeOptions, CommandListener listener) {
if (modals.isEmpty()) {
listener.onSuccess(root.getId());
return;
}
String topModalId = peek().getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ public void onSuccess(String childId) {
verifyZeroInteractions(listener);
}

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

@Test
public void dismissAllModals_optionsAreMergedOnTopModal() {
uut.showModal(modal1, root, new CommandListenerAdapter());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ public void dismissModal_rejectIfRootIsNotSetAndSingleModalIsDisplayed() {
public void dismissAllModals_onViewAppearedInvokedOnRoot() {
disablePushAnimation(child2);
disableShowModalAnimation(child1);
uut.setRoot(child3, new CommandListenerAdapter(), reactInstanceManager);

uut.dismissAllModals(Options.EMPTY, new CommandListenerAdapter());
verify(parentVisibilityListener, times(0)).onViewAppeared(parentController.getView());
Expand Down

0 comments on commit ec03383

Please sign in to comment.