@@ -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