Methods
-
reset()
-
Resets specific information called method.
Example
mock("obj").should_receive("something"); mock("obj").should_receive("something2"); obj.something(); obj.something2(); mock("obj").verify("something"); // {"total" : 1, param : {}} mock("obj").verify("something2"); // {"total" : 1, param : {}} mock("obj").reset("something"); mock("obj").verify("something"); // throw new Error(`something isn't called.`); mock("obj").verify("something2"); // {"total" : 1, param : {}}
-
reset_all()
-
Resets all information called methods.
Example
mock("obj").should_receive("something"); mock("obj").should_receive("something2"); obj.something(); obj.something2(); mock("obj").verify("something"); // {"total" : 1, param : {}} mock("obj").verify("something2"); // {"total" : 1, param : {}} mock("obj").reset_all(); mock("obj").verify("something"); // throw new Error(`something isn't called.`); mock("obj").verify("something2"); // throw new Error(`something2 isn't called.`);
-
should_receive(methodName)
-
should_receive make method in mock.
Parameters:
Name Type Description methodName
string method name in mock.
Returns:
- Type
- MockMethod
Example
mock("obj").should_receive("something"); // obj.something(); mock("Sample",mock.INSTANCE).should_receive("something"); // let sample = new Sample(); // sample.something(); // class Test // end // let test = new Test(); mock(test).should_receive("something"); // test.something(); mock(Test,mock.INSTANCE).should_receive("instance"); // let test = new Test(); // test.instance()
-
verify()
-
Return specific information called method.
Example
mock("obj").should_receive("something"); obj.something(); mock("obj").verify("something"); // {"total" : 1, param : {}}
-
verify_all()
-
Return all information called methods.
Example
mock("obj").should_receive("something"); mock("obj").should_receive("something2"); obj.something(); obj.something2(); mock("obj").verify_all(); //{ // "something": {total" : 1, param : {}} // "something2": {total" : 1, param : {}} //}