Skip to content

Effects immediately firing instead of after store.receive call in test #1244

Discussion options

You must be logged in to vote

Whoops! For anyone who encounters the same problem, it turns out it's because I was not setting the 'setUserInterfaceStyle' closure correctly in my test:

let environment = update(AppDelegateEnvironment.failing) {
  $0.mainQueue = mainQueue.eraseToAnyScheduler()

  // Wrong
  $0.setUserInterfaceStyle = { _ in didSetUserInterfaceStyle = true; return .none }

  // Right
  $0.setUserInterfaceStyle = { _ in
    .fireAndForget {
      didSetUserInterfaceStyle = true
    }
  }
}

I also noticed that they do this test in SettingsFeature (which is how I found the answer). I suppose by adding it as a simple closure, it may have the same kind of behavior as Combine's Future objects, where it just fi…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by acosmicflamingo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant