I'm trying to unit test a closure that works just fine, but for whatever reason the compiler throws this Function is unused
error in the test. I'm passing the parameter. What am I missing?
This is the closure's definition:
configuration.router.didSelectProduct = { navigationController in
{ product in
let vc = More.build(navigationController: navigationController)
navigationController.pushViewController(vc, animated: true)
}
}
Note that the closure variable is optional so I'm force unwrapping it for simplicity.
CodePudding user response:
The problem with your code is that didSelectProduct
is a nested closure, and you are missing the parameter for the inner closure. You can provide a second parameter like:
didSelectProduct!(navController)(someProduct)