1
- import { inject , async , TestBed } from '@angular/core/testing' ;
1
+ import { inject , async , fakeAsync , tick , TestBed } from '@angular/core/testing' ;
2
2
import { SafeResourceUrl , DomSanitizer } from '@angular/platform-browser' ;
3
3
import { HttpModule , XHRBackend } from '@angular/http' ;
4
4
import { MockBackend } from '@angular/http/testing' ;
@@ -126,7 +126,7 @@ describe('MatIcon', () => {
126
126
} ) ;
127
127
128
128
describe ( 'Icons from URLs' , ( ) => {
129
- it ( 'should register icon URLs by name' , ( ) => {
129
+ it ( 'should register icon URLs by name' , fakeAsync ( ( ) => {
130
130
iconRegistry . addSvgIcon ( 'fluffy' , trust ( 'cat.svg' ) ) ;
131
131
iconRegistry . addSvgIcon ( 'fido' , trust ( 'dog.svg' ) ) ;
132
132
@@ -153,7 +153,14 @@ describe('MatIcon', () => {
153
153
svgElement = verifyAndGetSingleSvgChild ( matIconElement ) ;
154
154
verifyPathChildElement ( svgElement , 'woof' ) ;
155
155
expect ( httpRequestUrls ) . toEqual ( [ 'dog.svg' , 'cat.svg' ] ) ;
156
- } ) ;
156
+
157
+ // Assert that a registered icon can be looked-up by url.
158
+ iconRegistry . getSvgIconFromUrl ( trust ( 'cat.svg' ) ) . subscribe ( element => {
159
+ verifyPathChildElement ( element , 'meow' ) ;
160
+ } ) ;
161
+
162
+ tick ( ) ;
163
+ } ) ) ;
157
164
158
165
it ( 'should throw an error when using an untrusted icon url' , ( ) => {
159
166
iconRegistry . addSvgIcon ( 'fluffy' , 'farm-set-1.svg' ) ;
0 commit comments