You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 15, 2025. It is now read-only.
'Invalid source prop. <CacheableImage> props.source.uri should be a web accessible url with a valid protocol and host. NOTE: Default valid protocol is https, default valid hosts are *.',
Copy file name to clipboardExpand all lines: tests/CacheableImage.test.tsx
+35-47Lines changed: 35 additions & 47 deletions
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,9 @@ import { shallow } from 'enzyme'
9
9
importReactfrom'react'
10
10
11
11
describe('CacheableImage',function(){
12
+
constoriginalWarn=console.warn
13
+
afterEach(()=>(console.warn=originalWarn))
14
+
12
15
it('HOC options validation should work as expected.',()=>{
13
16
// Check validation is catching bad option input.
14
17
try{
@@ -174,74 +177,59 @@ describe('CacheableImage', function () {
174
177
})
175
178
176
179
it('#_validateImageComponent should validate bad component props correctly.',()=>{
180
+
constconsoleOutput=[]
181
+
console.warn=(output)=>consoleOutput.push(output)
182
+
177
183
// Verify source uri prop only accepts web accessible urls.
178
184
179
185
constCacheableImage=imageCacheHoc(Image)
180
186
181
-
try{
182
-
// eslint-disable-next-line no-unused-vars
183
-
constcacheableImage=newCacheableImage({
184
-
source: {
185
-
uri: './local-file.jpg',
186
-
},
187
-
})
187
+
newCacheableImage({
188
+
source: {
189
+
uri: './local-file.jpg',
190
+
},
191
+
})
188
192
189
-
thrownewError('Invalid source uri prop was accepted.')
190
-
}catch(error){
191
-
error.should.deepEqual(
192
-
newError(
193
-
'Invalid source prop. <CacheableImage> props.source.uri should be a web accessible url with a valid protocol and host. NOTE: Default valid protocol is https, default valid hosts are *.',
194
-
),
195
-
)
196
-
}
193
+
expect(consoleOutput).toEqual([
194
+
'Invalid source prop. <CacheableImage> props.source.uri should be a web accessible url with a valid protocol and host. NOTE: Default valid protocol is https, default valid hosts are *.',
195
+
])
197
196
198
197
// Verify source uri prop only accepts web accessible urls from whitelist if whitelist set.
thrownewError('Invalid source uri prop was accepted.')
214
-
}catch(error){
215
-
error.should.deepEqual(
216
-
newError(
217
-
'Invalid source prop. <CacheableImage> props.source.uri should be a web accessible url with a valid protocol and host. NOTE: Default valid protocol is https, default valid hosts are *.',
218
-
),
219
-
)
220
-
}
210
+
expect(consoleOutput).toEqual([
211
+
'Invalid source prop. <CacheableImage> props.source.uri should be a web accessible url with a valid protocol and host. NOTE: Default valid protocol is https, default valid hosts are *.',
212
+
'Invalid source prop. <CacheableImage> props.source.uri should be a web accessible url with a valid protocol and host. NOTE: Default valid protocol is https, default valid hosts are *.',
213
+
])
221
214
222
215
// Verify source uri prop only accepts web accessible urls from correct protocols if protocol list set.
thrownewError('Invalid source uri prop was accepted.')
238
-
}catch(error){
239
-
error.should.deepEqual(
240
-
newError(
241
-
'Invalid source prop. <CacheableImage> props.source.uri should be a web accessible url with a valid protocol and host. NOTE: Default valid protocol is https, default valid hosts are *.',
242
-
),
243
-
)
244
-
}
228
+
expect(consoleOutput).toEqual([
229
+
'Invalid source prop. <CacheableImage> props.source.uri should be a web accessible url with a valid protocol and host. NOTE: Default valid protocol is https, default valid hosts are *.',
230
+
'Invalid source prop. <CacheableImage> props.source.uri should be a web accessible url with a valid protocol and host. NOTE: Default valid protocol is https, default valid hosts are *.',
231
+
'Invalid source prop. <CacheableImage> props.source.uri should be a web accessible url with a valid protocol and host. NOTE: Default valid protocol is https, default valid hosts are *.',
232
+
])
245
233
})
246
234
247
235
it('Verify component is actually still mounted before calling setState() in componentDidMount().',async()=>{
0 commit comments