shouldBeCalledWith(mockName, funcName, params)

Defines an expectation for a mocked function. i.e. after your test is complete, Maddox will compare the actual parameters the mock was called with to the defined exepected parameters from this function. If a mocked function (from 'mockThisFunction') is called once, then 'shouldBeCalledWith' should be defined once for that mocked function. If a mocked function is called 'n' times, then 'shouldBeCalledWith' should be defined 'n' times for that mocked function.

Ordering matters when defining these expectations. If your function is called 3 times, Maddox will compare the first set of actual parameters to the first set of defined expected parameters and so on.

If your function takes a callback you should NOT add this to the params array. The callback will be automatically validated during execution when you use 'doesReturnWithCallback'.

  • mockName {String} - This is the key for the mock. It should match the key from 'mockThisFunction'.
  • funcName {String} - The name of the function to be mocked. Should match the name from 'mockThisFunction'.
  • params {Array} - An array of expected parameters. First parameter of the function goes in index 0 and the nth parameter of the function goes into index n.
  • returns {Scenario}