Commit dce4d184 by Ivana Huckova Committed by GitHub

Fix regex in convertCSSToStyle, add test coverage (#21508)

parent a35b2ac4
......@@ -33,4 +33,20 @@ describe('<LogMessageAnsi />', () => {
.text()
).toBe('ipsum');
});
it('renders string with ANSI codes with correctly converted css classnames', () => {
const value = 'Lorem Ipsum';
const wrapper = shallow(<LogMessageAnsi value={value} />);
expect(wrapper.find('span')).toHaveLength(1);
expect(
wrapper
.find('span')
.first()
.prop('style')
).toMatchObject(
expect.objectContaining({
fontWeight: expect.any(String),
})
);
});
});
......@@ -15,7 +15,7 @@ function convertCSSToStyle(css: string): Style {
const match = line.match(/([^:\s]+)\s*:\s*(.+)/);
if (match && match[1] && match[2]) {
const key = match[1].replace(/-(a-z)/g, (_, character) => character.toUpperCase());
const key = match[1].replace(/-([a-z])/g, (_, character) => character.toUpperCase());
// @ts-ignore
accumulated[key] = match[2];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment