import React from 'react';
import { Icon } from '../../dist/offline';
import renderer from 'react-test-renderer';
const iconDataWithID = {
body: '',
width: 128,
height: 128,
};
describe('Replacing IDs', () => {
test('default behavior', () => {
const component = renderer.create();
const tree = component.toJSON();
const body = tree.props.dangerouslySetInnerHTML.__html;
// Check that default id doesn't exist
expect(body.indexOf('ssvg-id-1st-place-medala')).toEqual(-1);
});
test('custom generator', () => {
const component = renderer.create(
);
const tree = component.toJSON();
const body = tree.props.dangerouslySetInnerHTML.__html;
// Generate expected body
let expected = iconDataWithID.body;
const replacements = {
'ssvg-id-1st-place-medala': 'testID0',
'ssvg-id-1st-place-medald': 'testID1',
'ssvg-id-1st-place-medalf': 'testID2',
'ssvg-id-1st-place-medalh': 'testID3',
'ssvg-id-1st-place-medalj': 'testID4',
'ssvg-id-1st-place-medalm': 'testID5',
'ssvg-id-1st-place-medalp': 'testID6',
'ssvg-id-1st-place-medalb': 'testID7',
'ssvg-id-1st-place-medalk': 'testID8',
'ssvg-id-1st-place-medalo': 'testID9',
'ssvg-id-1st-place-medalc': 'testID10',
'ssvg-id-1st-place-medale': 'testID11',
'ssvg-id-1st-place-medalg': 'testID12',
'ssvg-id-1st-place-medali': 'testID13',
'ssvg-id-1st-place-medall': 'testID14',
'ssvg-id-1st-place-medaln': 'testID15',
};
Object.keys(replacements).forEach((search) => {
expected = expected.replace(
new RegExp(search, 'g'),
replacements[search]
);
});
expect(body).toStrictEqual(expected);
});
});