2019-09-25 17:11:13 +02:00
|
|
|
/*
|
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
2021-02-04 03:12:39 +01:00
|
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
|
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
|
|
* 2.0.
|
2019-09-25 17:11:13 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import { mount } from 'enzyme';
|
|
|
|
import { VisualizationContainer } from './visualization_container';
|
|
|
|
|
|
|
|
describe('VisualizationContainer', () => {
|
|
|
|
test('renders reporting data attributes when ready', () => {
|
|
|
|
const component = mount(<VisualizationContainer isReady={true}>Hello!</VisualizationContainer>);
|
|
|
|
|
|
|
|
const reportingEl = component.find('[data-shared-item]').first();
|
|
|
|
expect(reportingEl.prop('data-render-complete')).toBeTruthy();
|
|
|
|
expect(reportingEl.prop('data-shared-item')).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('does not render data attributes when not ready', () => {
|
|
|
|
const component = mount(
|
|
|
|
<VisualizationContainer isReady={false}>Hello!</VisualizationContainer>
|
|
|
|
);
|
|
|
|
|
|
|
|
const reportingEl = component.find('[data-shared-item]').first();
|
|
|
|
expect(reportingEl.prop('data-render-complete')).toBeFalsy();
|
|
|
|
expect(reportingEl.prop('data-shared-item')).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('renders child content', () => {
|
|
|
|
const component = mount(
|
|
|
|
<VisualizationContainer isReady={false}>Hello!</VisualizationContainer>
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(component.text()).toEqual('Hello!');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('defaults to rendered', () => {
|
|
|
|
const component = mount(<VisualizationContainer>Hello!</VisualizationContainer>);
|
|
|
|
const reportingEl = component.find('[data-shared-item]').first();
|
|
|
|
|
|
|
|
expect(reportingEl.prop('data-render-complete')).toBeTruthy();
|
|
|
|
expect(reportingEl.prop('data-shared-item')).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
2020-10-01 18:02:37 +02:00
|
|
|
test('renders title and description for reporting, if provided', () => {
|
2019-09-25 17:11:13 +02:00
|
|
|
const component = mount(
|
2020-10-01 18:02:37 +02:00
|
|
|
<VisualizationContainer reportTitle="shazam!" reportDescription="Description">
|
|
|
|
Hello!
|
|
|
|
</VisualizationContainer>
|
2019-09-25 17:11:13 +02:00
|
|
|
);
|
|
|
|
const reportingEl = component.find('[data-shared-item]').first();
|
|
|
|
|
|
|
|
expect(reportingEl.prop('data-title')).toEqual('shazam!');
|
2020-10-01 18:02:37 +02:00
|
|
|
expect(reportingEl.prop('data-description')).toEqual('Description');
|
2019-09-25 17:11:13 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
test('renders style', () => {
|
|
|
|
const component = mount(
|
|
|
|
<VisualizationContainer style={{ color: 'blue' }}>Hello!</VisualizationContainer>
|
|
|
|
);
|
|
|
|
const reportingEl = component.find('[data-shared-item]').first();
|
|
|
|
|
|
|
|
expect(reportingEl.prop('style')).toEqual({ color: 'blue' });
|
|
|
|
});
|
2020-07-13 14:59:16 +02:00
|
|
|
|
|
|
|
test('combines class names with container class', () => {
|
|
|
|
const component = mount(
|
|
|
|
<VisualizationContainer className="myClass">Hello!</VisualizationContainer>
|
|
|
|
);
|
|
|
|
const reportingEl = component.find('[data-shared-item]').first();
|
|
|
|
|
|
|
|
expect(reportingEl.prop('className')).toEqual('myClass lnsVisualizationContainer');
|
|
|
|
});
|
2019-09-25 17:11:13 +02:00
|
|
|
});
|