Skip to content

Commit ab5a544

Browse files
committed
fix: do not remove spaces in runnable title
1 parent e5bdf96 commit ab5a544

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

src/test-reader/test-object/test-object.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,18 @@ class TestObject {
1919
return this.#title;
2020
}
2121

22+
titlePath() {
23+
if (this.parent) {
24+
const parentTitlePath = this.parent.titlePath();
25+
26+
return this.title ? parentTitlePath.concat(this.title) : parentTitlePath;
27+
}
28+
29+
return this.title ? [this.title] : [];
30+
}
31+
2232
fullTitle() {
23-
return `${(this.parent && this.parent.fullTitle()) || ""} ${this.title || ""}`.trim();
33+
return this.titlePath().join(" ");
2434
}
2535
}
2636

test/src/test-reader/test-object/test-object.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ describe("test-reader/test-object/test-object", () => {
3838
});
3939
});
4040

41+
describe("titlePath", () => {
42+
it("should return all parent titles", () => {
43+
const obj = new TestObject({ title: " bar " });
44+
obj.parent = new TestObject({ title: " foo " });
45+
46+
assert.deepEqual(obj.titlePath(), [" foo ", " bar "]);
47+
});
48+
});
49+
4150
describe("fullTitle", () => {
4251
it("should return title if no parent", () => {
4352
const obj = new TestObject({ title: "foo bar" });
@@ -53,26 +62,31 @@ describe("test-reader/test-object/test-object", () => {
5362

5463
it("should return include parent full title", () => {
5564
const obj = new TestObject({ title: "baz qux" });
56-
obj.parent = new TestObject({});
57-
sinon.stub(obj.parent, "fullTitle").returns("foo bar");
65+
obj.parent = new TestObject({ title: "foo bar" });
5866

5967
assert.equal(obj.fullTitle(), "foo bar baz qux");
6068
});
6169

6270
it("should have no spaces at the beginning if parent has no title", () => {
6371
const obj = new TestObject({ title: "foo bar" });
6472
obj.parent = new TestObject({});
65-
sinon.stub(obj.parent, "fullTitle").returns("");
6673

6774
assert.equal(obj.fullTitle(), "foo bar");
6875
});
6976

7077
it("should have no spaces at the end if object has no title", () => {
7178
const obj = new TestObject({});
72-
obj.parent = new TestObject({});
73-
sinon.stub(obj.parent, "fullTitle").returns("foo bar");
79+
obj.parent = new TestObject({ title: "foo bar" });
7480

7581
assert.equal(obj.fullTitle(), "foo bar");
7682
});
83+
84+
it("should not remove any spaces", () => {
85+
const obj = new TestObject({ title: "baz " });
86+
obj.parent = new TestObject({ title: "bar " });
87+
obj.parent.parent = new TestObject({ title: " foo " });
88+
89+
assert.equal(obj.fullTitle(), " foo bar baz ");
90+
});
7791
});
7892
});

0 commit comments

Comments
 (0)