Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doing block is not working in multiple expectation #13

Closed
RohitNegi opened this issue Jul 14, 2021 · 4 comments
Closed

doing block is not working in multiple expectation #13

RohitNegi opened this issue Jul 14, 2021 · 4 comments

Comments

@RohitNegi
Copy link

RohitNegi commented Jul 14, 2021

`func test_getYearsFilter_if() {

    //given
    var capturedCompletionBlock: ((YearsFilterResponse) -> Void)?
    let yearsFilterResponseObject = YearsFilterResponse()
    yearsFilterResponseObject.years = ["2020", "2019", "2018"]
    let  statementFilterModel =  [StatementFilterModel]()
    //expect

    mockMFStatementRepo.expect { m in
        m.getYearsFilter { (_) in } failure: { (_) in }
    }.doing { (actionArgs) in
        capturedCompletionBlock = actionArgs[0] as? ((YearsFilterResponse) -> Void)
    }
    // expect
    mockMFStatementRepo.expect { o in
        o.getMfStatementFilter()
    }.returning(statementFilterModel)

    //when
    viewModel.getYearsFilter()
    //then
    mockMFStatementRepo.verify()
    // then later, call that captured block to simulate an incoming response
    capturedCompletionBlock?(yearsFilterResponseObject)

    //Assert
    XCTAssertEqual(viewModel.yearsFilterOptions, yearsFilterResponseObject.years)

}`
@mflint
Copy link
Owner

mflint commented Jul 14, 2021

Thank-you for raising an issue @RohitNegi, but I'll need more information to understand the problem.

Can you explain please:

  • what you expect to happen
  • what actually happens

@mflint
Copy link
Owner

mflint commented Jul 14, 2021

Oh, I think I understand. This seems to be related to #12.

Investigating!

@mflint
Copy link
Owner

mflint commented Jul 15, 2021

Can this issue be closed @RohitNegi ?

@RohitNegi
Copy link
Author

Yes, it can be, thanks @mflint

@mflint mflint closed this as completed Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants