import { getRenderMode } from '../src/attributes/mode';
describe('Testing getRenderMode', () => {
// Default mode is 'svg'? Change this value if code in state/mode.ts changes
const defautToSVG = true;
it('Force mode', () => {
expect(getRenderMode('', 'svg')).toBe('svg');
expect(getRenderMode('', 'bg')).toBe('bg');
expect(getRenderMode('', 'mask')).toBe('mask');
});
it('Style', () => {
expect(getRenderMode('', 'style')).toBe('bg');
expect(
getRenderMode('', 'style')
).toBe('mask');
});
it('Detect mode', () => {
// Icon without 'currentColor'
expect(getRenderMode('', null)).toBe(defautToSVG ? 'svg' : 'bg');
expect(getRenderMode('', '')).toBe(defautToSVG ? 'svg' : 'bg');
// Icon with 'currentColor'
expect(
getRenderMode('', '')
).toBe(defautToSVG ? 'svg' : 'mask');
expect(
getRenderMode(
'',
'whatever'
)
).toBe(defautToSVG ? 'svg' : 'mask');
});
it('Animated icons', () => {
// Animated icon without 'currentColor'
const animatedDefaultFill =
'';
expect(getRenderMode(animatedDefaultFill, 'svg')).toBe('svg');
expect(getRenderMode(animatedDefaultFill, 'bg')).toBe('bg');
expect(getRenderMode(animatedDefaultFill, 'mask')).toBe('mask');
expect(getRenderMode(animatedDefaultFill, '')).toBe('bg');
expect(getRenderMode(animatedDefaultFill, 'style')).toBe('bg');
// Animated icon with 'currentColor'
const animatedCurrentColor =
'';
expect(getRenderMode(animatedCurrentColor, 'svg')).toBe('svg');
expect(getRenderMode(animatedCurrentColor, 'bg')).toBe('bg');
expect(getRenderMode(animatedCurrentColor, 'mask')).toBe('mask');
expect(getRenderMode(animatedCurrentColor, '')).toBe('mask');
expect(getRenderMode(animatedCurrentColor, 'style')).toBe('mask');
});
});