@@ -2,9 +2,10 @@ import { Component } from "@angular/core";
2
2
import { ComponentFixture , TestBed } from "@angular/core/testing" ;
3
3
import { By } from "@angular/platform-browser" ;
4
4
import { ButtonModule } from "../button" ;
5
- import { IconModule } from "../icon" ;
5
+ import { IconModule , IconService } from "../icon" ;
6
6
import { ContainedListItem } from "./contained-list-item.component" ;
7
-
7
+ import Apple16 from "@carbon/icons/es/apple/16" ;
8
+ import Fish16 from "@carbon/icons/es/fish/16" ;
8
9
import { ContainedList } from "./contained-list.component" ;
9
10
import { ContainedListKind , ContainedListSize } from "./contained-list.enums" ;
10
11
@@ -25,20 +26,25 @@ import { ContainedListKind, ContainedListSize } from "./contained-list.enums";
25
26
</ng-template>
26
27
27
28
<ng-template #icon>
28
- <svg ibmIcon="add " size="16"></svg>
29
+ <svg ibmIcon="fish " size="16"></svg>
29
30
</ng-template>
30
31
31
32
<cds-contained-list [label]="label" [action]="action">
32
33
<cds-contained-list-item>List item</cds-contained-list-item>
33
34
<cds-contained-list-item [icon]="icon">List item with icon</cds-contained-list-item>
35
+ <cds-contained-list-item icon="apple">List item with string ref icon</cds-contained-list-item>
34
36
<cds-contained-list-item [action]="action">List item with action</cds-contained-list-item>
35
37
<cds-contained-list-item #clickableListItem [clickable]="true">
36
38
<ng-container ibmContainedListItemButton>Clickable list item</ng-container>
37
39
</cds-contained-list-item>
38
40
</cds-contained-list>
39
41
`
40
42
} )
41
- class WrapperComponent { }
43
+ class WrapperComponent {
44
+ constructor ( private iconService : IconService ) {
45
+ this . iconService . registerAll ( [ Apple16 , Fish16 ] ) ;
46
+ }
47
+ }
42
48
43
49
describe ( "ContainedList" , ( ) => {
44
50
let component : ContainedList ;
@@ -127,23 +133,31 @@ describe("ContainedList", () => {
127
133
const wrapperFixture : ComponentFixture < WrapperComponent > = TestBed . createComponent ( WrapperComponent ) ;
128
134
wrapperFixture . detectChanges ( ) ;
129
135
130
- const iconElement = wrapperFixture . debugElement . query ( By . css ( ".cds--contained-list-item:nth-child(2) svg" ) ) ;
136
+ const iconElement = wrapperFixture . debugElement . query ( By . css ( ".cds--contained-list-item:nth-child(2) svg[ibmIcon='fish']" ) ) ;
137
+ expect ( iconElement ) . toBeTruthy ( ) ;
138
+ } ) ;
139
+
140
+ it ( "should render the icon" , ( ) => {
141
+ const wrapperFixture : ComponentFixture < WrapperComponent > = TestBed . createComponent ( WrapperComponent ) ;
142
+ wrapperFixture . detectChanges ( ) ;
143
+
144
+ const iconElement = wrapperFixture . debugElement . query ( By . css ( ".cds--contained-list-item:nth-child(3) svg[ng-reflect-ibm-icon='apple']" ) ) ;
131
145
expect ( iconElement ) . toBeTruthy ( ) ;
132
146
} ) ;
133
147
134
148
it ( "should render the action" , ( ) => {
135
149
const wrapperFixture : ComponentFixture < WrapperComponent > = TestBed . createComponent ( WrapperComponent ) ;
136
150
wrapperFixture . detectChanges ( ) ;
137
151
138
- const actionElement = wrapperFixture . debugElement . query ( By . css ( ".cds--contained-list-item:nth-child(3 ) ibm-icon-button" ) ) ;
152
+ const actionElement = wrapperFixture . debugElement . query ( By . css ( ".cds--contained-list-item:nth-child(4 ) ibm-icon-button" ) ) ;
139
153
expect ( actionElement ) . toBeTruthy ( ) ;
140
154
} ) ;
141
155
142
156
it ( "should render with the clickable state" , ( ) => {
143
157
const wrapperFixture : ComponentFixture < WrapperComponent > = TestBed . createComponent ( WrapperComponent ) ;
144
158
wrapperFixture . detectChanges ( ) ;
145
159
146
- const clickableListItemElement = wrapperFixture . debugElement . query ( By . css ( ".cds--contained-list-item:nth-child(4 )" ) ) ;
160
+ const clickableListItemElement = wrapperFixture . debugElement . query ( By . css ( ".cds--contained-list-item:nth-child(5 )" ) ) ;
147
161
expect ( clickableListItemElement . nativeElement ) . toHaveClass ( "cds--contained-list-item--clickable" ) ;
148
162
149
163
const buttonElement = clickableListItemElement . nativeElement . querySelector ( "button" ) ;
0 commit comments