@@ -6,7 +6,7 @@ import {DocsAppTestingModule} from '../../testing/testing-module';
66import { DocViewer } from './doc-viewer' ;
77import { DocViewerModule } from './doc-viewer-module' ;
88import { ExampleViewer } from '../example-viewer/example-viewer' ;
9-
9+ import { MatTooltip } from '@angular/material/tooltip' ;
1010
1111describe ( 'DocViewer' , ( ) => {
1212 let http : HttpTestingController ;
@@ -149,6 +149,36 @@ describe('DocViewer', () => {
149149 expect ( console . error ) . toHaveBeenCalledTimes ( 1 ) ;
150150 } ) ;
151151
152+ it ( 'should show tooltip for deprecated symbol' , ( ) => {
153+ const fixture = TestBed . createComponent ( DocViewerTestComponent ) ;
154+ fixture . componentInstance . documentUrl = `http://material.angular.io/deprecated.html` ;
155+ fixture . detectChanges ( ) ;
156+
157+ const url = fixture . componentInstance . documentUrl ;
158+ http . expectOne ( url ) . flush ( FAKE_DOCS [ url ] ) ;
159+
160+ const docViewer = fixture . debugElement . query ( By . directive ( DocViewer ) ) ;
161+
162+ expect ( docViewer ) . not . toBeNull ( ) ;
163+
164+ // we have five deprecated symbols: class, constant, type alias, interface
165+ // and properties.
166+ expect ( docViewer . children . length ) . toBe ( 5 ) ;
167+
168+ // it should have "Deprecated" as its inner text
169+ const deprecatedSymbol = docViewer . children . shift ( ) ! ;
170+ expect ( deprecatedSymbol . nativeElement . innerText ) . toBe ( 'Deprecated' ) ;
171+
172+ // should contain the tooltip component
173+ const tooltipElement = deprecatedSymbol . children . shift ( ) ! ;
174+ expect ( tooltipElement . nativeElement ) . toBeTruthy ( ) ;
175+
176+ // should show tooltip on hovering the element
177+ tooltipElement . nativeNode . dispatchEvent ( new MouseEvent ( 'hover' ) ) ;
178+ fixture . detectChanges ( ) ;
179+ expect ( deprecatedSymbol . query ( By . directive ( MatTooltip ) ) ) . toBeTruthy ( ) ;
180+ } ) ;
181+
152182 // TODO(mmalerba): Add test that example-viewer is instantiated.
153183} ) ;
154184
@@ -177,6 +207,21 @@ const FAKE_DOCS: {[key: string]: string} = {
177207 '<div material-docs-example="demo-example"></div>' ,
178208 'http://material.angular.io/whole-snippet-example.html' :
179209 '<div material-docs-example="whole-snippet-example" file="whole-snippet-example.ts"></div>' ,
210+ 'http://material.angular.io/deprecated.html' :
211+ `<div class="docs-api-class-deprecated-marker"
212+ deprecated-message="deprecated class">Deprecated</div>
213+
214+ <div class="docs-api-constant-deprecated-marker"
215+ deprecated-message="deprecated constant">Deprecated</div>
216+
217+ <div class="docs-api-interface-deprecated-marker"
218+ deprecated-message="deprecated interface">Deprecated</div>
219+
220+ <div class="docs-api-type-alias-deprecated-marker"
221+ deprecated-message="deprecated type alias">Deprecated</div>
222+
223+ <div class="docs-api-deprecated-marker"
224+ deprecated-message="deprecated">Deprecated</div>` ,
180225 /* eslint-enable @typescript-eslint/naming-convention */
181226} ;
182227
0 commit comments