Closed m-vdb closed 7 years ago
Im unfamiliar with what prefetch actually does? Surely theres something we can add besides a blank function?
Image.prefetch()
is useful to pre-download a remote url (an image url) and save it to the disk for later use. I use it in order to avoid glitches when displaying remote images. We could for instance initialize a static 'cache' on the Image
and save the urls there, but I don't think it's a real good idea to implement a custom behavior.
(In my tests I would use it in concordance with sinon.stub()
to verify that Image.prefetch()
is called with the right urls)
Ah ok, sounds like a good idea. If image.prefetch is meant to return something, it might be worth returning something related to it's input, trying to replicate the functions IO instead of something dumb like this
not sure I understand what you mean. The prefetch()
method doesn't return anything. And I think it would be better to leave the mocking part to the tester (by using sinon
or any other mocking library).
Ah, I didnt realise it didnt return anything, in that case I think this is fine for a mock. Merging
Hi there,
First of all thanks for this nice project, it's really helping me with the tests :)
Here is a small PR to add support to Image.prefetch(). I didn't see any test that I could add but LMK if and where I can write some.