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,9 +36,21 @@ describe('Spec', function () {
});
});
it('getFullName returns suite & spec description', function () {
var spec = new jasmine.Spec(env, suite, 'spec 1');
expect(spec.getFullName()).toEqual('suite 1 spec 1.');
describe('full name', function() {
describe('with string', function() {
it('getFullName returns suite & spec description', function () {
var spec = new jasmine.Spec(env, suite, '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 () {
@ -121,4 +133,4 @@ describe('Spec', function () {
expect(logResult.values).toEqual(["here's some log message", {key: 'value'}, 123]);
});
});
});
});

View File

@ -29,7 +29,8 @@ jasmine.Spec = function(env, suite, description) {
};
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 + '.';
};