I have a service that is returning an image in base64 format. I want to write some unit tests for this and obviously want to go a little further that statusCode === 200
.
I have looked at this post that seems to get close to what I want with regex How to check whether the string is base64 encoded or not but it only matches if I remove the following:
"data:image/jpeg;base64,/9j"
This is what my response will look like:
{
"statusCode": 200,
"headers": {
"Content-Type": "image/jpeg"
},
"body": "data:image/jpeg;base64,/9j/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQY.........
}
If I am going in the wrong way with testing this, please let me know a better solution.