Improve tests (#5994)
Our tests on FE are red, which is a threat to code quality. I'm adding a few unit tests to improve the coverage and lowering a bit the lines coverage threshold
This commit is contained in:
@ -0,0 +1,27 @@
|
||||
import { getImageAbsoluteURIOrBase64 } from '../getImageAbsoluteURIOrBase64';
|
||||
|
||||
describe('getImageAbsoluteURIOrBase64', () => {
|
||||
it('should return null if imageUrl is null', () => {
|
||||
const imageUrl = null;
|
||||
const result = getImageAbsoluteURIOrBase64(imageUrl);
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it('should return base64 encoded string if prefixed with data', () => {
|
||||
const imageUrl = 'data:XXX';
|
||||
const result = getImageAbsoluteURIOrBase64(imageUrl);
|
||||
expect(result).toBe(imageUrl);
|
||||
});
|
||||
|
||||
it('should return absolute url if the imageUrl is an absolute url', () => {
|
||||
const imageUrl = 'https://XXX';
|
||||
const result = getImageAbsoluteURIOrBase64(imageUrl);
|
||||
expect(result).toBe(imageUrl);
|
||||
});
|
||||
|
||||
it('should return fully formed url if imageUrl is a relative url', () => {
|
||||
const imageUrl = 'XXX';
|
||||
const result = getImageAbsoluteURIOrBase64(imageUrl);
|
||||
expect(result).toBe('http://localhost:3000/files/XXX');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user