1
- import { wrappedErrorMessage } from '@angular/cdk/testing/private' ;
2
1
import {
3
- HttpClientTestingModule ,
2
+ provideHttpClientTesting ,
4
3
HttpTestingController ,
5
4
TestRequest ,
6
5
} from '@angular/common/http/testing' ;
@@ -9,7 +8,7 @@ import {TestBed, fakeAsync, tick, waitForAsync} from '@angular/core/testing';
9
8
import { DomSanitizer , SafeHtml , SafeResourceUrl } from '@angular/platform-browser' ;
10
9
import { FAKE_SVGS } from './fake-svgs' ;
11
10
import { MatIcon } from './icon' ;
12
- import { MatIconRegistry , getMatIconNoHttpProviderError } from './icon-registry' ;
11
+ import { MatIconRegistry } from './icon-registry' ;
13
12
import { MAT_ICON_DEFAULT_OPTIONS , MAT_ICON_LOCATION , MatIconModule } from './index' ;
14
13
15
14
/** Returns the CSS classes assigned to an element as a sorted array. */
@@ -65,7 +64,6 @@ describe('MatIcon', () => {
65
64
66
65
TestBed . configureTestingModule ( {
67
66
imports : [
68
- HttpClientTestingModule ,
69
67
MatIconModule ,
70
68
IconWithColor ,
71
69
IconWithLigature ,
@@ -80,6 +78,7 @@ describe('MatIcon', () => {
80
78
BlankIcon ,
81
79
] ,
82
80
providers : [
81
+ provideHttpClientTesting ( ) ,
83
82
{
84
83
provide : MAT_ICON_LOCATION ,
85
84
useValue : { getPathname : ( ) => fakePath } ,
@@ -1358,38 +1357,6 @@ describe('MatIcon', () => {
1358
1357
}
1359
1358
} ) ;
1360
1359
1361
- describe ( 'MatIcon without HttpClientModule' , ( ) => {
1362
- let iconRegistry : MatIconRegistry ;
1363
- let sanitizer : DomSanitizer ;
1364
-
1365
- @Component ( {
1366
- template : `<mat-icon [svgIcon]="iconName"></mat-icon>` ,
1367
- imports : [ MatIcon ] ,
1368
- } )
1369
- class IconFromSvgName {
1370
- iconName : string | undefined = '' ;
1371
- }
1372
-
1373
- beforeEach ( waitForAsync ( ( ) => {
1374
- iconRegistry = TestBed . inject ( MatIconRegistry ) ;
1375
- sanitizer = TestBed . inject ( DomSanitizer ) ;
1376
- } ) ) ;
1377
-
1378
- it ( 'should throw an error when trying to load a remote icon' , ( ) => {
1379
- const expectedError = wrappedErrorMessage ( getMatIconNoHttpProviderError ( ) ) ;
1380
-
1381
- expect ( ( ) => {
1382
- iconRegistry . addSvgIcon ( 'fido' , sanitizer . bypassSecurityTrustResourceUrl ( 'dog.svg' ) ) ;
1383
-
1384
- const fixture = TestBed . createComponent ( IconFromSvgName ) ;
1385
-
1386
- fixture . componentInstance . iconName = 'fido' ;
1387
- fixture . changeDetectorRef . markForCheck ( ) ;
1388
- fixture . detectChanges ( ) ;
1389
- } ) . toThrowError ( expectedError ) ;
1390
- } ) ;
1391
- } ) ;
1392
-
1393
1360
describe ( 'MatIcon with default options' , ( ) => {
1394
1361
it ( 'should be able to configure color globally' , fakeAsync ( ( ) => {
1395
1362
const fixture = createComponent ( IconWithLigature , [
@@ -1457,23 +1424,23 @@ describe('MatIcon with default options', () => {
1457
1424
1458
1425
@Component ( {
1459
1426
template : `<mat-icon>{{iconName}}</mat-icon>` ,
1460
- imports : [ HttpClientTestingModule , MatIconModule ] ,
1427
+ imports : [ MatIconModule ] ,
1461
1428
} )
1462
1429
class IconWithLigature {
1463
1430
iconName = '' ;
1464
1431
}
1465
1432
1466
1433
@Component ( {
1467
1434
template : `<mat-icon [fontIcon]="iconName"></mat-icon>` ,
1468
- imports : [ HttpClientTestingModule , MatIconModule ] ,
1435
+ imports : [ MatIconModule ] ,
1469
1436
} )
1470
1437
class IconWithLigatureByAttribute {
1471
1438
iconName = '' ;
1472
1439
}
1473
1440
1474
1441
@Component ( {
1475
1442
template : `<mat-icon [color]="iconColor">{{iconName}}</mat-icon>` ,
1476
- imports : [ HttpClientTestingModule , MatIconModule ] ,
1443
+ imports : [ MatIconModule ] ,
1477
1444
} )
1478
1445
class IconWithColor {
1479
1446
iconName = '' ;
@@ -1482,7 +1449,7 @@ class IconWithColor {
1482
1449
1483
1450
@Component ( {
1484
1451
template : `<mat-icon [fontSet]="fontSet" [fontIcon]="fontIcon"></mat-icon>` ,
1485
- imports : [ HttpClientTestingModule , MatIconModule ] ,
1452
+ imports : [ MatIconModule ] ,
1486
1453
} )
1487
1454
class IconWithCustomFontCss {
1488
1455
fontSet = '' ;
@@ -1491,21 +1458,21 @@ class IconWithCustomFontCss {
1491
1458
1492
1459
@Component ( {
1493
1460
template : `<mat-icon [svgIcon]="iconName"></mat-icon>` ,
1494
- imports : [ HttpClientTestingModule , MatIconModule ] ,
1461
+ imports : [ MatIconModule ] ,
1495
1462
} )
1496
1463
class IconFromSvgName {
1497
1464
iconName : string | undefined = '' ;
1498
1465
}
1499
1466
1500
1467
@Component ( {
1501
1468
template : '<mat-icon aria-hidden="false">face</mat-icon>' ,
1502
- imports : [ HttpClientTestingModule , MatIconModule ] ,
1469
+ imports : [ MatIconModule ] ,
1503
1470
} )
1504
1471
class IconWithAriaHiddenFalse { }
1505
1472
1506
1473
@Component ( {
1507
1474
template : `@if (showIcon) {<mat-icon [svgIcon]="iconName">{{iconName}}</mat-icon>}` ,
1508
- imports : [ HttpClientTestingModule , MatIconModule ] ,
1475
+ imports : [ MatIconModule ] ,
1509
1476
} )
1510
1477
class IconWithBindingAndNgIf {
1511
1478
iconName = 'fluffy' ;
@@ -1514,31 +1481,31 @@ class IconWithBindingAndNgIf {
1514
1481
1515
1482
@Component ( {
1516
1483
template : `<mat-icon [inline]="inline">{{iconName}}</mat-icon>` ,
1517
- imports : [ HttpClientTestingModule , MatIconModule ] ,
1484
+ imports : [ MatIconModule ] ,
1518
1485
} )
1519
1486
class InlineIcon {
1520
1487
inline = false ;
1521
1488
}
1522
1489
1523
1490
@Component ( {
1524
1491
template : `<mat-icon [svgIcon]="iconName"><div>Hello</div></mat-icon>` ,
1525
- imports : [ HttpClientTestingModule , MatIconModule ] ,
1492
+ imports : [ MatIconModule ] ,
1526
1493
} )
1527
1494
class SvgIconWithUserContent {
1528
1495
iconName : string | undefined = '' ;
1529
1496
}
1530
1497
1531
1498
@Component ( {
1532
1499
template : '<mat-icon [svgIcon]="iconName">house</mat-icon>' ,
1533
- imports : [ HttpClientTestingModule , MatIconModule ] ,
1500
+ imports : [ MatIconModule ] ,
1534
1501
} )
1535
1502
class IconWithLigatureAndSvgBinding {
1536
1503
iconName : string | undefined ;
1537
1504
}
1538
1505
1539
1506
@Component ( {
1540
1507
template : `<mat-icon></mat-icon>` ,
1541
- imports : [ HttpClientTestingModule , MatIconModule ] ,
1508
+ imports : [ MatIconModule ] ,
1542
1509
} )
1543
1510
class BlankIcon {
1544
1511
@ViewChild ( MatIcon ) icon : MatIcon ;
0 commit comments