Skip to content
Snippets Groups Projects

fix(overlays): fixed opacity for overlays generated by entity color

Merged Tadeusz Miesiąc requested to merge fix/overlays-color-alpha into development
1 unresolved thread
16 files
+ 388
174
Compare changes
  • Side-by-side
  • Inline
Files
16
import { OverlayBioEntityRender } from '@/types/OLrendering';
import { getColorByAvailableProperties } from './getColorByAvailableProperties';
describe('getColorByAvailableProperties', () => {
const ENTITY: OverlayBioEntityRender = {
id: 0,
modelId: 0,
x1: 0,
y1: 0,
x2: 0,
y2: 0,
width: 0,
height: 0,
value: null,
overlayId: 0,
color: null,
};
const getHexTricolorGradientColorWithAlpha = jest.fn().mockReturnValue('#FFFFFF');
const defaultColor = '#000000';
beforeEach(() => {
jest.clearAllMocks();
});
it('should return the result of getHexTricolorGradientColorWithAlpha if entity has a value equal to 0', () => {
const entity = { ...ENTITY, value: 0 };
const result = getColorByAvailableProperties(
entity,
getHexTricolorGradientColorWithAlpha,
defaultColor,
);
expect(result).toEqual('#FFFFFF');
expect(getHexTricolorGradientColorWithAlpha).toHaveBeenCalledWith(entity.value);
});
it('should return the result of getHexTricolorGradientColorWithAlpha if entity has a value', () => {
const entity = { ...ENTITY, value: -0.2137 };
const result = getColorByAvailableProperties(
entity,
getHexTricolorGradientColorWithAlpha,
defaultColor,
);
expect(result).toEqual('#FFFFFF');
expect(getHexTricolorGradientColorWithAlpha).toHaveBeenCalledWith(entity.value);
});
it('should return the result of convertDecimalToHex if entity has a color', () => {
const entity = { ...ENTITY, color: { rgb: -65536, alpha: 0 } }; // red color
const result = getColorByAvailableProperties(
entity,
getHexTricolorGradientColorWithAlpha,
defaultColor,
);
expect(result).toEqual('#ff0000');
expect(getHexTricolorGradientColorWithAlpha).not.toHaveBeenCalled();
});
it('should return the default color if entity has neither a value nor a color', () => {
const result = getColorByAvailableProperties(
ENTITY,
getHexTricolorGradientColorWithAlpha,
defaultColor,
);
expect(result).toEqual('#000000');
expect(getHexTricolorGradientColorWithAlpha).not.toHaveBeenCalled();
});
});
Loading