2019-01-15 18:53:27 -05:00
|
|
|
/**
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
* or more contributor license agreements. See the NOTICE file
|
|
|
|
* distributed with this work for additional information
|
|
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
|
|
* to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
2016-09-20 16:45:27 -04:00
|
|
|
import React from 'react';
|
|
|
|
import { shallow, mount } from 'enzyme';
|
|
|
|
import { OverlayTrigger } from 'react-bootstrap';
|
2018-02-13 20:21:15 -05:00
|
|
|
import sinon from 'sinon';
|
2016-09-20 16:45:27 -04:00
|
|
|
|
2020-05-07 17:18:10 -04:00
|
|
|
import EmbedCodeButton from 'src/explore/components/EmbedCodeButton';
|
|
|
|
import * as exploreUtils from 'src/explore/exploreUtils';
|
2016-09-20 16:45:27 -04:00
|
|
|
|
|
|
|
describe('EmbedCodeButton', () => {
|
|
|
|
const defaultProps = {
|
2018-02-13 20:21:15 -05:00
|
|
|
latestQueryFormData: { datasource: '107__table' },
|
2016-09-20 16:45:27 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
it('renders', () => {
|
2019-11-27 17:02:48 -05:00
|
|
|
expect(React.isValidElement(<EmbedCodeButton {...defaultProps} />)).toBe(
|
|
|
|
true,
|
|
|
|
);
|
2016-09-20 16:45:27 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders overlay trigger', () => {
|
|
|
|
const wrapper = shallow(<EmbedCodeButton {...defaultProps} />);
|
2018-10-15 16:10:18 -04:00
|
|
|
expect(wrapper.find(OverlayTrigger)).toHaveLength(1);
|
2016-09-20 16:45:27 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('returns correct embed code', () => {
|
2019-11-27 17:02:48 -05:00
|
|
|
const stub = sinon
|
|
|
|
.stub(exploreUtils, 'getExploreLongUrl')
|
|
|
|
.callsFake(() => 'endpoint_url');
|
2016-09-20 16:45:27 -04:00
|
|
|
const wrapper = mount(<EmbedCodeButton {...defaultProps} />);
|
|
|
|
wrapper.setState({
|
|
|
|
height: '1000',
|
|
|
|
width: '2000',
|
|
|
|
});
|
2019-11-27 17:02:48 -05:00
|
|
|
const embedHTML =
|
2017-01-06 15:38:44 -05:00
|
|
|
'<iframe\n' +
|
|
|
|
' width="2000"\n' +
|
|
|
|
' height="1000"\n' +
|
|
|
|
' seamless\n' +
|
|
|
|
' frameBorder="0"\n' +
|
|
|
|
' scrolling="no"\n' +
|
2018-10-15 16:10:18 -04:00
|
|
|
' src="http://localhostendpoint_url&height=1000"\n' +
|
2017-01-06 15:38:44 -05:00
|
|
|
'>\n' +
|
2019-11-27 17:02:48 -05:00
|
|
|
'</iframe>';
|
2018-10-15 16:10:18 -04:00
|
|
|
expect(wrapper.instance().generateEmbedHTML()).toBe(embedHTML);
|
2018-02-13 20:21:15 -05:00
|
|
|
stub.restore();
|
2016-09-20 16:45:27 -04:00
|
|
|
});
|
|
|
|
});
|