From 5583b6f954ad9e90835f857c2a7476cc1d88dfce Mon Sep 17 00:00:00 2001 From: Gregg Van Hove Date: Thu, 25 Feb 2016 14:29:35 -0800 Subject: [PATCH] Top-level specs should compute fullName the same as Suites - No longer include "Jasmine__TopLevel__Suite" --- lib/jasmine-core/jasmine.js | 16 +++++++++++----- spec/core/SuiteSpec.js | 4 ++-- src/core/Env.js | 8 +++++++- src/core/Suite.js | 8 ++++---- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 6222bbea..c0491a76 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -627,7 +627,13 @@ getJasmineRequireObj().Env = function(j$) { }; var getSpecName = function(spec, suite) { - return suite.getFullName() + ' ' + spec.description; + var fullName = [spec.description], + suiteFullName = suite.getFullName(); + + if (suiteFullName !== '') { + fullName.unshift(suiteFullName); + } + return fullName.join(' '); }; // TODO: we may just be able to pass in the fn instead of wrapping here @@ -2185,13 +2191,13 @@ getJasmineRequireObj().Suite = function(j$) { }; Suite.prototype.getFullName = function() { - var fullName = this.description; - for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { + var fullName = []; + for (var parentSuite = this; parentSuite; parentSuite = parentSuite.parentSuite) { if (parentSuite.parentSuite) { - fullName = parentSuite.description + ' ' + fullName; + fullName.unshift(parentSuite.description); } } - return fullName; + return fullName.join(' '); }; Suite.prototype.disable = function() { diff --git a/spec/core/SuiteSpec.js b/spec/core/SuiteSpec.js index b376dafd..92fa59d9 100644 --- a/spec/core/SuiteSpec.js +++ b/spec/core/SuiteSpec.js @@ -11,14 +11,14 @@ describe("Suite", function() { expect(suite.id).toEqual(456); }); - it("returns its full name", function() { + it("returns blank full name for top level suite", function() { var env = new jasmineUnderTest.Env(), suite = new jasmineUnderTest.Suite({ env: env, description: "I am a suite" }); - expect(suite.getFullName()).toEqual("I am a suite"); + expect(suite.getFullName()).toEqual(""); }); it("returns its full name when it has parent suites", function() { diff --git a/src/core/Env.js b/src/core/Env.js index b9326939..2b484747 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -123,7 +123,13 @@ getJasmineRequireObj().Env = function(j$) { }; var getSpecName = function(spec, suite) { - return suite.getFullName() + ' ' + spec.description; + var fullName = [spec.description], + suiteFullName = suite.getFullName(); + + if (suiteFullName !== '') { + fullName.unshift(suiteFullName); + } + return fullName.join(' '); }; // TODO: we may just be able to pass in the fn instead of wrapping here diff --git a/src/core/Suite.js b/src/core/Suite.js index 81ec5d09..459b0751 100644 --- a/src/core/Suite.js +++ b/src/core/Suite.js @@ -29,13 +29,13 @@ getJasmineRequireObj().Suite = function(j$) { }; Suite.prototype.getFullName = function() { - var fullName = this.description; - for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { + var fullName = []; + for (var parentSuite = this; parentSuite; parentSuite = parentSuite.parentSuite) { if (parentSuite.parentSuite) { - fullName = parentSuite.description + ' ' + fullName; + fullName.unshift(parentSuite.description); } } - return fullName; + return fullName.join(' '); }; Suite.prototype.disable = function() {