Nicer pretty printing of spy objects.
This commit is contained in:
parent
ee5905d237
commit
b0ae461139
@ -73,5 +73,21 @@ describe("jasmine.pp", function () {
|
|||||||
expect(jasmine.pp(window)).toEqual("<window>");
|
expect(jasmine.pp(window)).toEqual("<window>");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should stringify Date objects properly", function() {
|
||||||
|
var now = new Date();
|
||||||
|
expect(jasmine.pp(now)).toEqual("Date(" + now.toString() + ")");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should stringify spy objects properly", function() {
|
||||||
|
var TestObject = {
|
||||||
|
someFunction: function() {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
spyOn(TestObject, 'someFunction');
|
||||||
|
expect(jasmine.pp(TestObject.someFunction)).toEqual("spy on someFunction");
|
||||||
|
|
||||||
|
expect(jasmine.pp(jasmine.createSpy("something"))).toEqual("spy on something");
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
|
|||||||
this.emitScalar(value.toString());
|
this.emitScalar(value.toString());
|
||||||
} else if (typeof value === 'string') {
|
} else if (typeof value === 'string') {
|
||||||
this.emitString(value);
|
this.emitString(value);
|
||||||
|
} else if (jasmine.isSpy(value)) {
|
||||||
|
this.emitScalar("spy on " + value.identity);
|
||||||
} else if (typeof value === 'function') {
|
} else if (typeof value === 'function') {
|
||||||
this.emitScalar('Function');
|
this.emitScalar('Function');
|
||||||
} else if (typeof value.nodeType === 'number') {
|
} else if (typeof value.nodeType === 'number') {
|
||||||
|
Loading…
Reference in New Issue
Block a user