mirror of
https://github.com/apache/superset.git
synced 2026-04-07 18:35:15 +00:00
feat: use shorten url in standalone iframe (#10651)
This commit is contained in:
@@ -23,6 +23,7 @@ import sinon from 'sinon';
|
||||
|
||||
import EmbedCodeButton from 'src/explore/components/EmbedCodeButton';
|
||||
import * as exploreUtils from 'src/explore/exploreUtils';
|
||||
import * as common from 'src/utils/common';
|
||||
|
||||
describe('EmbedCodeButton', () => {
|
||||
const defaultProps = {
|
||||
@@ -40,14 +41,32 @@ describe('EmbedCodeButton', () => {
|
||||
expect(wrapper.find(OverlayTrigger)).toExist();
|
||||
});
|
||||
|
||||
it('returns correct embed code', () => {
|
||||
const stub = sinon
|
||||
.stub(exploreUtils, 'getExploreLongUrl')
|
||||
.callsFake(() => 'endpoint_url');
|
||||
it('should create shorten, standalone, explore url', () => {
|
||||
const spy1 = sinon.spy(exploreUtils, 'getExploreLongUrl');
|
||||
const spy2 = sinon.spy(common, 'getShortUrl');
|
||||
|
||||
const wrapper = mount(<EmbedCodeButton {...defaultProps} />);
|
||||
wrapper.setState({
|
||||
height: '1000',
|
||||
width: '2000',
|
||||
shortUrl: 'http://localhostendpoint_url&height=1000',
|
||||
});
|
||||
|
||||
const trigger = wrapper.find(OverlayTrigger);
|
||||
trigger.simulate('click');
|
||||
expect(spy1.args[0][1]).toBe('standalone');
|
||||
expect(spy2.callCount).toBe(1);
|
||||
|
||||
spy1.restore();
|
||||
spy2.restore();
|
||||
});
|
||||
|
||||
it('returns correct embed code', () => {
|
||||
const wrapper = mount(<EmbedCodeButton {...defaultProps} />);
|
||||
wrapper.setState({
|
||||
height: '1000',
|
||||
width: '2000',
|
||||
shortUrl: 'http://localhostendpoint_url&height=1000',
|
||||
});
|
||||
const embedHTML =
|
||||
'<iframe\n' +
|
||||
@@ -60,6 +79,5 @@ describe('EmbedCodeButton', () => {
|
||||
'>\n' +
|
||||
'</iframe>';
|
||||
expect(wrapper.instance().generateEmbedHTML()).toBe(embedHTML);
|
||||
stub.restore();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user