@@ -106,25 +106,25 @@ describe('Spans', () => {
106106 expect ( textBase . formattedText . spans . getItem ( 1 ) . text ) . toBe ( '1' ) ;
107107 expect ( textBase . formattedText . spans . getItem ( 2 ) . text ) . toBe ( '2' ) ;
108108 } ) ;
109- it ( 'correctly adds dynamically' , async ( ) => {
109+ it ( 'correctly adds dynamically when show is true' , ( ) => {
110110 const fixture = TestBed . createComponent ( DynamicSpansComponent ) ;
111- const textBase = fixture . componentInstance . textBase . nativeElement ;
111+ // default show = true
112112 fixture . detectChanges ( ) ;
113+ const textBase = fixture . componentInstance . textBase . nativeElement ;
113114 expect ( textBase . formattedText . spans . length ) . toBe ( 3 ) ;
114115 expect ( textBase . formattedText . spans . getItem ( 0 ) . text ) . toBe ( '0' ) ;
115116 expect ( textBase . formattedText . spans . getItem ( 1 ) . text ) . toBe ( '1' ) ;
116117 expect ( textBase . formattedText . spans . getItem ( 2 ) . text ) . toBe ( '2' ) ;
118+ } ) ;
119+
120+ it ( 'correctly adds dynamically when show is false' , ( ) => {
121+ const fixture = TestBed . createComponent ( DynamicSpansComponent ) ;
117122 fixture . componentInstance . show = false ;
118123 fixture . detectChanges ( ) ;
124+ const textBase = fixture . componentInstance . textBase . nativeElement ;
119125 expect ( textBase . formattedText . spans . length ) . toBe ( 2 ) ;
120126 expect ( textBase . formattedText . spans . getItem ( 0 ) . text ) . toBe ( '0' ) ;
121127 expect ( textBase . formattedText . spans . getItem ( 1 ) . text ) . toBe ( '2' ) ;
122- fixture . componentInstance . show = true ;
123- fixture . detectChanges ( ) ;
124- expect ( textBase . formattedText . spans . length ) . toBe ( 3 ) ;
125- expect ( textBase . formattedText . spans . getItem ( 0 ) . text ) . toBe ( '0' ) ;
126- expect ( textBase . formattedText . spans . getItem ( 1 ) . text ) . toBe ( '1' ) ;
127- expect ( textBase . formattedText . spans . getItem ( 2 ) . text ) . toBe ( '2' ) ;
128128 } ) ;
129129
130130 it ( 'correctly adds FormattedString' , async ( ) => {
@@ -137,25 +137,25 @@ describe('Spans', () => {
137137 expect ( textBase . formattedText . spans . getItem ( 2 ) . text ) . toBe ( '2' ) ;
138138 } ) ;
139139
140- it ( 'correctly adds FormattedString dynamically' , async ( ) => {
140+ it ( 'correctly adds FormattedString dynamically when show is true' , ( ) => {
141141 const fixture = TestBed . createComponent ( DynamicFormattedStringComponent ) ;
142- const textBase = fixture . componentInstance . textBase . nativeElement ;
142+ // default show = true
143143 fixture . detectChanges ( ) ;
144+ const textBase = fixture . componentInstance . textBase . nativeElement ;
144145 expect ( textBase . formattedText . spans . length ) . toBe ( 3 ) ;
145146 expect ( textBase . formattedText . spans . getItem ( 0 ) . text ) . toBe ( '0' ) ;
146147 expect ( textBase . formattedText . spans . getItem ( 1 ) . text ) . toBe ( '1' ) ;
147148 expect ( textBase . formattedText . spans . getItem ( 2 ) . text ) . toBe ( '2' ) ;
149+ } ) ;
150+
151+ it ( 'correctly adds FormattedString dynamically when show is false' , ( ) => {
152+ const fixture = TestBed . createComponent ( DynamicFormattedStringComponent ) ;
148153 fixture . componentInstance . show = false ;
149154 fixture . detectChanges ( ) ;
155+ const textBase = fixture . componentInstance . textBase . nativeElement ;
150156 expect ( textBase . formattedText . spans . length ) . toBe ( 2 ) ;
151157 expect ( textBase . formattedText . spans . getItem ( 0 ) . text ) . toBe ( '0' ) ;
152158 expect ( textBase . formattedText . spans . getItem ( 1 ) . text ) . toBe ( '2' ) ;
153- fixture . componentInstance . show = true ;
154- fixture . detectChanges ( ) ;
155- expect ( textBase . formattedText . spans . length ) . toBe ( 3 ) ;
156- expect ( textBase . formattedText . spans . getItem ( 0 ) . text ) . toBe ( '0' ) ;
157- expect ( textBase . formattedText . spans . getItem ( 1 ) . text ) . toBe ( '1' ) ;
158- expect ( textBase . formattedText . spans . getItem ( 2 ) . text ) . toBe ( '2' ) ;
159159 } ) ;
160160 } ) ;
161161 }
0 commit comments