Namespace TH.Mock
Mock out objects using a fairly simple interface. Also adds some counting functions.
Defined in: screw.mock.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Mock out objects using a fairly simple interface.
|
Field Attributes | Field Name and Description |
---|---|
<static> |
TH.Mock.mockedObjects
the mocked out objects
|
Method Attributes | Method Name and Description |
---|---|
<static> |
TH.Mock.numberOfCallsTo()
this will let you call TH.Mock.numberOfCallsTo("name", "prop") - for convenience
|
<static> |
TH.Mock.obj(mockString, newObj)
main mocking interface
|
<static> |
TH.Mock.reset()
Used in a before() to reset all the objects that have been mocked to their original splendor
|
Namespace Detail
TH.Mock
Mock out objects using a fairly simple interface. Also adds some counting functions.
var someObj = { foo: function () { return 'bar' } }; someObj.foo() == 'bar'; TH.Mock.Obj("someObj", { foo: function () { return 'somethingElse' } }); someObj.foo() == 'somethingElse'; // BUT! Only for this test the next test will have a normal someObj;
var someObj = { foo: function () { return 'bar' } }; someObj.foo() == 'bar'; TH.Mock.Obj("someObj"); someObj.countCallsOf("foo"); someObj.foo() == true; someObj.numberOfCallsTo("foo") == 1; // using that you can then do cool expectations: expect(someObj.numberOfCallsTo("foo")).to(equal, 1);
Field Detail
<static>
TH.Mock.mockedObjects
the mocked out objects
Method Detail
<static>
TH.Mock.numberOfCallsTo()
this will let you call TH.Mock.numberOfCallsTo("name", "prop") - for convenience
<static>
TH.Mock.obj(mockString, newObj)
main mocking interface
- Parameters:
- {String} mockString
- the string representation of the object you are trying to mock
- {Object} newObj
- (optional) functions you want to mock on the other object
- Throws:
- if the mockString does not eval into an object
- See:
- TH.Mock
<static>
TH.Mock.reset()
Used in a before() to reset all the objects that have been mocked to their original splendor