This repository was archived by the owner on Sep 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,28 @@ describe('<md-contact-chips>', function() {
60
60
expect ( ctrl . highlightFlags ) . toEqual ( 'i' ) ;
61
61
} ) ;
62
62
63
+ it ( 'renders an image element for contacts with an image property' , function ( ) {
64
+ scope . contacts . push ( scope . allContacts [ 2 ] ) ;
65
+
66
+ var element = buildChips ( CONTACT_CHIPS_TEMPLATE ) ;
67
+ var ctrl = element . controller ( 'mdContactChips' ) ;
68
+ var chip = angular . element ( element [ 0 ] . querySelector ( '.md-chip-content' ) ) ;
69
+
70
+ expect ( chip . find ( 'img' ) . length ) . toBe ( 1 ) ;
71
+ } ) ;
72
+
73
+ it ( 'does not render an image element for contacts without an image property' , function ( ) {
74
+ var noImageContact = scope . allContacts [ 2 ] ;
75
+ delete noImageContact . image ;
76
+ scope . contacts . push ( noImageContact ) ;
77
+
78
+ var element = buildChips ( CONTACT_CHIPS_TEMPLATE ) ;
79
+ var ctrl = element . controller ( 'mdContactChips' ) ;
80
+ var chip = angular . element ( element [ 0 ] . querySelector ( '.md-chip-content' ) ) ;
81
+
82
+ expect ( chip . find ( 'img' ) . length ) . toBe ( 0 ) ;
83
+ } ) ;
84
+
63
85
describe ( 'filtering selected items' , function ( ) {
64
86
it ( 'should filter' , inject ( function ( ) {
65
87
scope . querySearch = jasmine . createSpy ( 'querySearch' ) . and . callFake ( function ( q ) {
Original file line number Diff line number Diff line change @@ -69,7 +69,8 @@ var MD_CONTACT_CHIPS_TEMPLATE = '\
69
69
<div class="md-contact-suggestion">\
70
70
<img \
71
71
ng-src="{{item[$mdContactChipsCtrl.contactImage]}}"\
72
- alt="{{item[$mdContactChipsCtrl.contactName]}}" />\
72
+ alt="{{item[$mdContactChipsCtrl.contactName]}}"\
73
+ ng-if="item[$mdContactChipsCtrl.contactImage]" />\
73
74
<span class="md-contact-name" md-highlight-text="$mdContactChipsCtrl.searchText"\
74
75
md-highlight-flags="{{$mdContactChipsCtrl.highlightFlags}}">\
75
76
{{item[$mdContactChipsCtrl.contactName]}}\
@@ -81,7 +82,8 @@ var MD_CONTACT_CHIPS_TEMPLATE = '\
81
82
<div class="md-contact-avatar">\
82
83
<img \
83
84
ng-src="{{$chip[$mdContactChipsCtrl.contactImage]}}"\
84
- alt="{{$chip[$mdContactChipsCtrl.contactName]}}" />\
85
+ alt="{{$chip[$mdContactChipsCtrl.contactName]}}"\
86
+ ng-if="$chip[$mdContactChipsCtrl.contactImage]" />\
85
87
</div>\
86
88
<div class="md-contact-name">\
87
89
{{$chip[$mdContactChipsCtrl.contactName]}}\
You can’t perform that action at this time.
0 commit comments