[Expression Renderer] Fix Expression Renderer className composition (#86094)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Marco Liberati 2020-12-23 15:53:44 +01:00 committed by GitHub
parent 0f838bfea1
commit e575af3386
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View file

@ -304,4 +304,22 @@ describe('ExpressionRenderer', () => {
expect(onEvent).toHaveBeenCalledTimes(1);
expect(onEvent.mock.calls[0][0]).toBe(event);
});
it('should correctly assign classes to the wrapper node', () => {
(ExpressionLoader as jest.Mock).mockImplementation(() => {
return {
render$: new Subject(),
data$: new Subject(),
loading$: new Subject(),
update: jest.fn(),
destroy: jest.fn(),
};
});
const instance = mount(<ReactExpressionRenderer className="myClassName" expression="" />);
// Counte is 2 because the class is applied to ReactExpressionRenderer + internal component
expect(instance.find('.myClassName').length).toBe(2);
instance.unmount();
});
});

View file

@ -211,10 +211,9 @@ export const ReactExpressionRenderer = ({
}
}, [state.error]);
const classes = classNames('expExpressionRenderer', {
const classes = classNames('expExpressionRenderer', className, {
'expExpressionRenderer-isEmpty': state.isEmpty,
'expExpressionRenderer-hasError': !!state.error,
className,
});
const expressionStyles: React.CSSProperties = {};