@@ -1912,6 +1912,47 @@ namespace FourSlash {
19121912 }
19131913 }
19141914
1915+ public verifyNavigationBarCount ( count : number ) {
1916+ const actual = this . navigationBarItems ( ) . length ;
1917+ if ( actual !== count ) {
1918+ this . raiseError ( `Expected ${ count } items in navigation bar, got ${ actual } ` ) ;
1919+ }
1920+ }
1921+
1922+ public verifyNavigationBarItem ( text : string , kind : string ) {
1923+ this . verifyNavigationBarItemExists ( this . navigationBarItems ( ) , text , kind ) ;
1924+ }
1925+
1926+ public verifyNavigationBarChildItem ( parent : string , text : string , kind : string ) {
1927+ const items = this . navigationBarItems ( ) ;
1928+
1929+ // TODO: ts.find?
1930+ for ( let i = 0 ; i < items . length ; i ++ ) {
1931+ const item = items [ i ] ;
1932+ if ( item . text === parent ) {
1933+ this . verifyNavigationBarItemExists ( item . childItems , text , kind ) ;
1934+ return ;
1935+ }
1936+ }
1937+
1938+ this . raiseError ( `Could not find any parent named ${ parent } in: ${ JSON . stringify ( items , undefined , 2 ) } ` ) ;
1939+ }
1940+
1941+ private navigationBarItems ( ) {
1942+ return this . languageService . getNavigationBarItems ( this . activeFile . fileName ) ;
1943+ }
1944+
1945+ private verifyNavigationBarItemExists ( items : ts . NavigationBarItem [ ] , text : string , kind : string ) {
1946+ for ( let i = 0 ; i < items . length ; i ++ ) {
1947+ const item = items [ i ] ;
1948+ if ( item . text === text && item . kind === kind ) {
1949+ return ;
1950+ }
1951+ }
1952+
1953+ this . raiseError ( `Could not find ${ JSON . stringify ( { text, kind} , undefined , 2 ) } in the navigation bar: ${ JSON . stringify ( items , undefined , 2 ) } ` ) ;
1954+ }
1955+
19151956 /*
19161957 Check number of navigationItems which match both searchValue and matchKind.
19171958 Report an error if expected value and actual value do not match.
@@ -3044,6 +3085,18 @@ namespace FourSlashInterface {
30443085 this . state . verifyGetScriptLexicalStructureListContains ( name , kind ) ;
30453086 }
30463087
3088+ public navigationBarCount ( count : number ) {
3089+ this . state . verifyNavigationBarCount ( count ) ;
3090+ }
3091+
3092+ public navigationBarItem ( text : string , kind : string ) {
3093+ this . state . verifyNavigationBarItem ( text , kind ) ;
3094+ }
3095+
3096+ public navigationBarChildItem ( parent : string , text : string , kind : string ) {
3097+ this . state . verifyNavigationBarChildItem ( parent , text , kind ) ;
3098+ }
3099+
30473100 public navigationItemsListCount ( count : number , searchValue : string , matchKind ?: string ) {
30483101 this . state . verifyNavigationItemsCount ( count , searchValue , matchKind ) ;
30493102 }
0 commit comments