@@ -87,22 +87,17 @@ describe('UserStatsComponent', () => {
8787 const header = getDOM ( ) . querySelector ( el , 'h2' ) ;
8888 expect ( header . innerText ) . toMatch ( / t e s t 1 / ) ;
8989
90- const profileLink = getDOM ( ) . querySelector ( el , 'section:first-child a ' ) ;
90+ const profileLink = getDOM ( ) . querySelector ( el , 'a[href="/users/1"] ' ) ;
9191 expect ( profileLink ) . toBeTruthy ( ) ;
92- expect ( profileLink . getAttribute ( 'href' ) ) . toEqual ( '/users/1' ) ;
9392
94- const postCnt = getDOM ( ) . querySelector ( el , 'section:first-child > span:last-child' ) ;
95- expect ( postCnt ) . toBeTruthy ( ) ;
96- expect ( postCnt . innerText ) . toMatch ( / 2 m i c r o p o s t s / ) ;
93+ expect ( el . innerText ) . toMatch ( / 2 m i c r o p o s t s / ) ;
9794
98- const followingsLink = getDOM ( ) . querySelector ( el , 'section:last-child a:first-child ' ) ;
95+ const followingsLink = getDOM ( ) . querySelector ( el , 'a[href="/users/1/followings"] ' ) ;
9996 expect ( followingsLink ) . toBeTruthy ( ) ;
100- expect ( followingsLink . getAttribute ( 'href' ) ) . toEqual ( '/users/1/followings' ) ;
10197 expect ( followingsLink . innerText ) . toMatch ( / 3 [ \s \S ] * ?f o l l o w i n g s / ) ;
10298
103- const followersLink = getDOM ( ) . querySelector ( el , 'section:last-child a:last-child ' ) ;
99+ const followersLink = getDOM ( ) . querySelector ( el , 'a[href="/users/1/followers"] ' ) ;
104100 expect ( followersLink ) . toBeTruthy ( ) ;
105- expect ( followersLink . getAttribute ( 'href' ) ) . toEqual ( '/users/1/followers' ) ;
106101 expect ( followersLink . innerText ) . toMatch ( / 4 [ \s \S ] * ?f o l l o w e r s / ) ;
107102 } ) ;
108103
@@ -114,13 +109,13 @@ describe('UserStatsComponent', () => {
114109 } ) ;
115110
116111 it ( 'does not show profile link' , ( ) => {
117- const profileLink = getDOM ( ) . querySelector ( cmpDebugElement . nativeElement , 'a.profile-link' ) ;
118- expect ( profileLink ) . toBeFalsy ( ) ;
112+ const el = cmpDebugElement . nativeElement ;
113+ expect ( el . innerText ) . not . toMatch ( / v i e w m y p r o f i l e / ) ;
119114 } ) ;
120115
121116 it ( 'does not show post counts' , ( ) => {
122- const postCnt = getDOM ( ) . querySelector ( cmpDebugElement . nativeElement , '.microposts' ) ;
123- expect ( postCnt ) . toBeFalsy ( ) ;
117+ const el = cmpDebugElement . nativeElement ;
118+ expect ( el . innerText ) . not . toMatch ( / \d + m i c r o p o s t s ? / ) ;
124119 } ) ;
125120 } ) ;
126121
0 commit comments