Files
superset2/superset/assets/spec/javascripts/explore/components/EmbedCodeButton_spec.jsx
Maxime Beauchemin 222671675c [exploreV2] mapStateToProps for fields (#1882)
* Controls support for mapStateToProps

* Binding methods in the constructor

* Adressing comments

* Fixing tests
2017-01-06 12:38:44 -08:00

48 lines
1.3 KiB
JavaScript

import React from 'react';
import { expect } from 'chai';
import { describe, it } from 'mocha';
import { shallow, mount } from 'enzyme';
import { OverlayTrigger } from 'react-bootstrap';
import EmbedCodeButton from '../../../../javascripts/explore/components/EmbedCodeButton';
describe('EmbedCodeButton', () => {
const defaultProps = {
slice: {
data: {
standalone_endpoint: 'endpoint_url',
},
},
};
it('renders', () => {
expect(React.isValidElement(<EmbedCodeButton {...defaultProps} />)).to.equal(true);
});
it('renders overlay trigger', () => {
const wrapper = shallow(<EmbedCodeButton {...defaultProps} />);
expect(wrapper.find(OverlayTrigger)).to.have.length(1);
});
it('returns correct embed code', () => {
const wrapper = mount(<EmbedCodeButton {...defaultProps} />);
wrapper.setState({
height: '1000',
width: '2000',
srcLink: 'http://localhost/endpoint_url',
});
const embedHTML = (
'<iframe\n' +
' width="2000"\n' +
' height="1000"\n' +
' seamless\n' +
' frameBorder="0"\n' +
' scrolling="no"\n' +
' src="nullendpoint_url&height=1000"\n' +
'>\n' +
'</iframe>'
);
expect(wrapper.instance().generateEmbedHTML()).to.equal(embedHTML);
});
});