This method can help you verify that at least a minimum number of calls have been made to all mocked methods or a specific mocked method.
Boolean $atLeast(minNumberOfInvocations,[methodname])
Parameters:
minNumberOfInvocations - The min number of calls to assert
methodName - The optional method name to assert the number of method calls
// let's say we have a service that verifies user credentials// and if not valid, then tries to check if the user can be inflated from a cookie// and then verified againfunction verifyUser(){​if( isValidUser() ){log.info("user is valid, doing valid operations");}​// check if user cookie existsif( isUserCookieValid() ){// inflate credentialsinflateUserFromCookie();// Validate them againif( NOT isValidUser() ){log.error("user from cookie invalid, aborting");}}}​// Now the testit( "can verify a user", function(){security = createMock("model.security").$("isValidUser",false);security.storeUserCookie("invalid");security.verifyUser();​// Asserts that isValidUser() has been called at least 5 timesexpect( security.$atLeast(5,"isValidUser") ).toBeFalse();// Asserts that isValidUser() has been called at least 2 timesexpect( security.$atLeast(2,"isValidUser") ).toBeFalse();});