1
1
import {
2
- it ,
3
- describe ,
4
- expect ,
5
- beforeEach ,
6
- beforeEachProviders ,
7
- inject ,
8
- TestComponentBuilder ,
2
+ it ,
3
+ describe ,
4
+ expect ,
5
+ beforeEach ,
6
+ beforeEachProviders ,
7
+ inject ,
8
+ TestComponentBuilder
9
9
} from 'angular2/testing' ;
10
- import {
11
- HTTP_PROVIDERS ,
12
- XHRBackend } from 'angular2/http' ;
10
+ import { HTTP_PROVIDERS , XHRBackend } from 'angular2/http' ;
13
11
import { MockBackend } from 'angular2/http/testing' ;
14
- import {
15
- provide ,
16
- Component } from 'angular2/core' ;
17
-
12
+ import { provide , Component } from 'angular2/core' ;
18
13
import { MdIcon } from './icon' ;
19
14
import { MdIconRegistry } from './icon-registry' ;
20
15
import { getFakeSvgHttpResponse } from './fake-svgs' ;
21
16
17
+
18
+
22
19
/** Returns the CSS classes assigned to an element as a sorted array. */
23
20
const sortedClassNames = ( elem : Element ) => elem . className . split ( ' ' ) . sort ( ) ;
24
21
@@ -74,7 +71,7 @@ export function main() {
74
71
75
72
describe ( 'Ligature icons' , ( ) => {
76
73
it ( 'should add material-icons class by default' , ( done : ( ) => void ) => {
77
- return builder . createAsync ( MdIconLigatureTestApp ) . then ( ( fixture ) => {
74
+ return builder . createAsync ( MdIconLigatureTestApp ) . then ( fixture => {
78
75
const testComponent = fixture . debugElement . componentInstance ;
79
76
const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
80
77
testComponent . iconName = 'home' ;
@@ -86,7 +83,7 @@ export function main() {
86
83
87
84
it ( 'should use alternate icon font if set' , ( done : ( ) => void ) => {
88
85
mdIconRegistry . setDefaultFontSetClass ( 'myfont' ) ;
89
- return builder . createAsync ( MdIconLigatureTestApp ) . then ( ( fixture ) => {
86
+ return builder . createAsync ( MdIconLigatureTestApp ) . then ( fixture => {
90
87
const testComponent = fixture . debugElement . componentInstance ;
91
88
const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
92
89
testComponent . iconName = 'home' ;
@@ -99,7 +96,7 @@ export function main() {
99
96
100
97
describe ( 'Icons from URLs' , ( ) => {
101
98
it ( 'should fetch SVG icon from URL and inline the content' , ( done : ( ) => void ) => {
102
- return builder . createAsync ( MdIconFromSvgUrlTestApp ) . then ( ( fixture ) => {
99
+ return builder . createAsync ( MdIconFromSvgUrlTestApp ) . then ( fixture => {
103
100
const testComponent = fixture . debugElement . componentInstance ;
104
101
const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
105
102
let svgElement : any ;
@@ -135,7 +132,7 @@ export function main() {
135
132
it ( 'should register icon URLs by name' , ( done : ( ) => void ) => {
136
133
mdIconRegistry . addSvgIcon ( 'fluffy' , 'cat.svg' ) ;
137
134
mdIconRegistry . addSvgIcon ( 'fido' , 'dog.svg' ) ;
138
- return builder . createAsync ( MdIconFromSvgNameTestApp ) . then ( ( fixture ) => {
135
+ return builder . createAsync ( MdIconFromSvgNameTestApp ) . then ( fixture => {
139
136
const testComponent = fixture . debugElement . componentInstance ;
140
137
const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
141
138
let svgElement : SVGElement ;
@@ -168,7 +165,7 @@ export function main() {
168
165
169
166
it ( 'should extract icon from SVG icon set' , ( done : ( ) => void ) => {
170
167
mdIconRegistry . addSvgIconSetInNamespace ( 'farm' , 'farm-set-1.svg' ) ;
171
- return builder . createAsync ( MdIconFromSvgNameTestApp ) . then ( ( fixture ) => {
168
+ return builder . createAsync ( MdIconFromSvgNameTestApp ) . then ( fixture => {
172
169
const testComponent = fixture . debugElement . componentInstance ;
173
170
const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
174
171
let svgElement : any ;
@@ -207,7 +204,7 @@ export function main() {
207
204
mdIconRegistry . addSvgIconSetInNamespace ( 'farm' , 'farm-set-1.svg' ) ;
208
205
mdIconRegistry . addSvgIconSetInNamespace ( 'farm' , 'farm-set-2.svg' ) ;
209
206
mdIconRegistry . addSvgIconSetInNamespace ( 'arrows' , 'arrow-set.svg' ) ;
210
- return builder . createAsync ( MdIconFromSvgNameTestApp ) . then ( ( fixture ) => {
207
+ return builder . createAsync ( MdIconFromSvgNameTestApp ) . then ( fixture => {
211
208
const testComponent = fixture . debugElement . componentInstance ;
212
209
const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
213
210
let svgElement : any ;
@@ -250,7 +247,7 @@ export function main() {
250
247
251
248
it ( 'should not wrap <svg> elements in icon sets in another svg tag' , ( done : ( ) => void ) => {
252
249
mdIconRegistry . addSvgIconSet ( 'arrow-set.svg' ) ;
253
- return builder . createAsync ( MdIconFromSvgNameTestApp ) . then ( ( fixture ) => {
250
+ return builder . createAsync ( MdIconFromSvgNameTestApp ) . then ( fixture => {
254
251
const testComponent = fixture . debugElement . componentInstance ;
255
252
const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
256
253
let svgElement : any ;
@@ -268,7 +265,7 @@ export function main() {
268
265
} ) ;
269
266
270
267
it ( 'should return unmodified copies of icons from URLs' , ( done : ( ) => void ) => {
271
- return builder . createAsync ( MdIconFromSvgUrlTestApp ) . then ( ( fixture ) => {
268
+ return builder . createAsync ( MdIconFromSvgUrlTestApp ) . then ( fixture => {
272
269
const testComponent = fixture . debugElement . componentInstance ;
273
270
const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
274
271
let svgElement : any ;
@@ -299,7 +296,7 @@ export function main() {
299
296
300
297
it ( 'should return unmodified copies of icons from icon sets' , ( done : ( ) => void ) => {
301
298
mdIconRegistry . addSvgIconSet ( 'arrow-set.svg' ) ;
302
- return builder . createAsync ( MdIconFromSvgNameTestApp ) . then ( ( fixture ) => {
299
+ return builder . createAsync ( MdIconFromSvgNameTestApp ) . then ( fixture => {
303
300
const testComponent = fixture . debugElement . componentInstance ;
304
301
const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
305
302
let svgElement : any ;
@@ -333,7 +330,7 @@ export function main() {
333
330
it ( 'should apply CSS classes for custom font and icon' , ( done : ( ) => void ) => {
334
331
mdIconRegistry . registerFontClassAlias ( 'f1' , 'font1' ) ;
335
332
mdIconRegistry . registerFontClassAlias ( 'f2' ) ;
336
- return builder . createAsync ( MdIconCustomFontCssTestApp ) . then ( ( fixture ) => {
333
+ return builder . createAsync ( MdIconCustomFontCssTestApp ) . then ( fixture => {
337
334
const testComponent = fixture . debugElement . componentInstance ;
338
335
const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
339
336
testComponent . fontSet = 'f1' ;
@@ -361,10 +358,12 @@ export function main() {
361
358
362
359
describe ( 'aria label' , ( ) => {
363
360
it ( 'should set aria label from text content if not specified' , ( done : ( ) => void ) => {
364
- return builder . createAsync ( MdIconLigatureTestApp ) . then ( ( fixture ) => {
361
+ return builder . createAsync ( MdIconLigatureTestApp ) . then ( fixture => {
362
+
365
363
const testComponent = fixture . debugElement . componentInstance ;
366
364
const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
367
365
testComponent . iconName = 'home' ;
366
+
368
367
fixture . detectChanges ( ) ;
369
368
expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBe ( 'home' ) ;
370
369
@@ -377,7 +376,7 @@ export function main() {
377
376
} ) ;
378
377
379
378
it ( 'should use alt tag if aria label is not specified' , ( done : ( ) => void ) => {
380
- return builder . createAsync ( MdIconLigatureWithAriaBindingTestApp ) . then ( ( fixture ) => {
379
+ return builder . createAsync ( MdIconLigatureWithAriaBindingTestApp ) . then ( fixture => {
381
380
const testComponent = fixture . debugElement . componentInstance ;
382
381
const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
383
382
testComponent . iconName = 'home' ;
@@ -394,7 +393,7 @@ export function main() {
394
393
} ) ;
395
394
396
395
it ( 'should use provided aria label rather than icon name' , ( done : ( ) => void ) => {
397
- return builder . createAsync ( MdIconLigatureWithAriaBindingTestApp ) . then ( ( fixture ) => {
396
+ return builder . createAsync ( MdIconLigatureWithAriaBindingTestApp ) . then ( fixture => {
398
397
const testComponent = fixture . debugElement . componentInstance ;
399
398
const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
400
399
testComponent . iconName = 'home' ;
@@ -406,7 +405,7 @@ export function main() {
406
405
} ) ;
407
406
408
407
it ( 'should use provided aria label rather than font icon' , ( done : ( ) => void ) => {
409
- return builder . createAsync ( MdIconCustomFontCssTestApp ) . then ( ( fixture ) => {
408
+ return builder . createAsync ( MdIconCustomFontCssTestApp ) . then ( fixture => {
410
409
const testComponent = fixture . debugElement . componentInstance ;
411
410
const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
412
411
testComponent . fontSet = 'f1' ;
0 commit comments