Compare commits

...

1 Commits

Author SHA1 Message Date
John Bintz c68ae4b144 better handling of nested suites 2011-06-08 13:28:18 -04:00
4 changed files with 27 additions and 7 deletions

View File

@ -1917,7 +1917,7 @@ jasmine.Spec = function(env, suite, description) {
};
jasmine.Spec.prototype.getFullName = function() {
var description = (this.description.apply ? this.description.name : this.description);
var description = (typeof this.description == 'function' || this.description instanceof Function) ? this.description.name : this.description;
return this.suite.getFullName() + ' ' + description + '.';
};
@ -2154,13 +2154,17 @@ jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
};
jasmine.Suite.prototype.getFullName = function() {
var fullName = (this.description.apply ? this.description.name : this.description);
var fullName = this.getDescription()
for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
fullName = parentSuite.description + ' ' + fullName;
fullName = parentSuite.getDescription() + ' ' + fullName;
}
return fullName;
};
jasmine.Suite.prototype.getDescription = function() {
return (typeof this.description == 'function' || this.description instanceof Function) ? this.description.name : this.description;
};
jasmine.Suite.prototype.finish = function(onComplete) {
this.env.reporter.reportSuiteResults(this);
this.finished = true;
@ -2469,5 +2473,5 @@ jasmine.version_= {
"major": 1,
"minor": 1,
"build": 0,
"revision": 1307455841
"revision": 1307554069
};

View File

@ -80,6 +80,18 @@ describe('Suite', function() {
expect(suite.getFullName()).toEqual("MyClass");
expect(suite.children()[0].getFullName()).toEqual("MyClass should be something.");
});
it('should use the name of the parent suite correctly', function() {
suite = env.describe(MyClass, function() {
env.describe('nested', function() {
env.it('should be something', function() {
});
});
});
expect(suite.getFullName()).toEqual("MyClass");
expect(suite.suites()[0].getFullName()).toEqual("MyClass nested");
});
});
});

View File

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

View File

@ -22,13 +22,17 @@ jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
};
jasmine.Suite.prototype.getFullName = function() {
var fullName = (this.description.apply ? this.description.name : this.description);
var fullName = this.getDescription()
for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
fullName = parentSuite.description + ' ' + fullName;
fullName = parentSuite.getDescription() + ' ' + fullName;
}
return fullName;
};
jasmine.Suite.prototype.getDescription = function() {
return (typeof this.description == 'function' || this.description instanceof Function) ? this.description.name : this.description;
};
jasmine.Suite.prototype.finish = function(onComplete) {
this.env.reporter.reportSuiteResults(this);
this.finished = true;