if a spec description is given a function as the description, use its name as the displayed description

This commit is contained in:
John Bintz 2011-06-07 09:47:30 -04:00
parent af7f1818b0
commit 222dda4e06
2 changed files with 18 additions and 5 deletions

View File

@ -36,10 +36,22 @@ describe('Spec', function () {
}); });
}); });
describe('full name', function() {
describe('with string', function() {
it('getFullName returns suite & spec description', function () { it('getFullName returns suite & spec description', function () {
var spec = new jasmine.Spec(env, suite, 'spec 1'); var spec = new jasmine.Spec(env, suite, 'spec 1');
expect(spec.getFullName()).toEqual('suite 1 spec 1.'); expect(spec.getFullName()).toEqual('suite 1 spec 1.');
}); });
});
describe('with class name', function () {
function MyClass() {}
it('getFullName returns suite & spec description', function () {
var spec = new jasmine.Spec(env, suite, MyClass);
expect(spec.getFullName()).toEqual('suite 1 MyClass.');
});
});
});
describe('results', function () { describe('results', function () {
var spec, results; var spec, results;

View File

@ -29,7 +29,8 @@ jasmine.Spec = function(env, suite, description) {
}; };
jasmine.Spec.prototype.getFullName = function() { jasmine.Spec.prototype.getFullName = function() {
return this.suite.getFullName() + ' ' + this.description + '.'; var description = (this.description.apply ? this.description.name : this.description);
return this.suite.getFullName() + ' ' + description + '.';
}; };