@@ -86,78 +86,88 @@ describe('getName', () => {
86
86
describe ( 'addIcons' , ( ) => {
87
87
it ( 'should add an svg to the icon cache' , ( ) => {
88
88
const testData = 'stubbed data' ;
89
-
89
+
90
90
expect ( getIconMap ( ) . get ( 'logo-ionic' ) ) . toEqual ( undefined ) ;
91
-
91
+
92
92
addIcons ( { 'logo-ionic' : 'stubbed data' } ) ;
93
-
93
+
94
94
expect ( getIconMap ( ) . get ( 'logo-ionic' ) ) . toEqual ( testData ) ;
95
95
} ) ;
96
-
96
+
97
97
it ( 'should add kebab and camel case names to the icon cache' , ( ) => {
98
98
const logoIonitron = 'stubbed data' ;
99
-
99
+
100
100
expect ( getIconMap ( ) . get ( 'logo-ionitron' ) ) . toEqual ( undefined ) ;
101
101
expect ( getIconMap ( ) . get ( 'logoIonitron' ) ) . toEqual ( undefined ) ;
102
-
102
+
103
103
addIcons ( { logoIonitron } ) ;
104
-
104
+
105
105
expect ( getIconMap ( ) . get ( 'logo-ionitron' ) ) . toEqual ( logoIonitron ) ;
106
106
expect ( getIconMap ( ) . get ( 'logoIonitron' ) ) . toEqual ( logoIonitron ) ;
107
+
108
+ const logoIonitron0 = 'stubbed data 0'
109
+
110
+ expect ( getIconMap ( ) . get ( 'logo-ionitron-0' ) ) . toEqual ( undefined ) ;
111
+ expect ( getIconMap ( ) . get ( 'logoIonitron0' ) ) . toEqual ( undefined ) ;
112
+
113
+ addIcons ( { logoIonitron0 } ) ;
114
+
115
+ expect ( getIconMap ( ) . get ( 'logo-ionitron-0' ) ) . toEqual ( logoIonitron0 ) ;
116
+ expect ( getIconMap ( ) . get ( 'logoIonitron0' ) ) . toEqual ( logoIonitron0 ) ;
107
117
} ) ;
108
-
118
+
109
119
it ( 'should map to a name that does not match the svg' , ( ) => {
110
120
const logoIonitron = 'stubbed data' ;
111
-
121
+
112
122
expect ( getIconMap ( ) . get ( 'my-fun-icon' ) ) . toEqual ( undefined ) ;
113
-
123
+
114
124
addIcons ( { 'my-fun-icon' : logoIonitron } ) ;
115
-
125
+
116
126
expect ( getIconMap ( ) . get ( 'my-fun-icon' ) ) . toEqual ( logoIonitron ) ;
117
127
} ) ;
118
-
128
+
119
129
it ( 'should map to an explicit camel case name' , ( ) => {
120
130
const logoIonitron = 'stubbed data' ;
121
-
131
+
122
132
expect ( getIconMap ( ) . get ( 'myCoolIcon' ) ) . toEqual ( undefined ) ;
123
-
133
+
124
134
addIcons ( { 'myCoolIcon' : logoIonitron } ) ;
125
-
135
+
126
136
expect ( getIconMap ( ) . get ( 'myCoolIcon' ) ) . toEqual ( logoIonitron ) ;
127
137
} ) ;
128
-
138
+
129
139
it ( 'should not warn when mapping the same icon twice' , ( ) => {
130
140
const spy = jest . spyOn ( console , 'warn' ) ;
131
141
132
142
const myIcon = 'my-icon' ;
133
-
143
+
134
144
expect ( spy ) . not . toHaveBeenCalled ( ) ;
135
-
145
+
136
146
addIcons ( { myIcon } ) ;
137
-
147
+
138
148
expect ( spy ) . not . toHaveBeenCalled ( ) ;
139
-
149
+
140
150
addIcons ( { myIcon } ) ;
141
-
151
+
142
152
expect ( spy ) . not . toHaveBeenCalled ( ) ;
143
153
} ) ;
144
-
154
+
145
155
it ( 'should not overwrite icons' , ( ) => {
146
156
const spy = jest . spyOn ( console , 'warn' ) ;
147
-
157
+
148
158
const logoA = 'logo a' ;
149
159
const logoB = 'logo b' ;
150
-
160
+
151
161
expect ( spy ) . not . toHaveBeenCalled ( ) ;
152
-
162
+
153
163
expect ( getIconMap ( ) . get ( 'logo-a' ) ) . toEqual ( undefined ) ;
154
-
164
+
155
165
addIcons ( { 'logo-a' : logoB , logoA } ) ;
156
-
166
+
157
167
expect ( getIconMap ( ) . get ( 'logo-a' ) ) . toEqual ( logoB ) ;
158
168
expect ( getIconMap ( ) . get ( 'logoA' ) ) . toEqual ( logoA ) ;
159
-
169
+
160
170
expect ( spy ) . toHaveBeenCalled ( ) ;
161
171
} ) ;
162
-
172
+
163
173
} ) ;
0 commit comments