mirror of
https://github.com/apache/superset.git
synced 2026-04-08 19:05:46 +00:00
* [lint] turn no-undef back on, set browser, cypress, and mocha env's, and fix issues * [lint] fix undefined var in TimeTable.jsx
59 lines
1.4 KiB
JavaScript
59 lines
1.4 KiB
JavaScript
import React from 'react';
|
|
import { Modal } from 'react-bootstrap';
|
|
import { expect } from 'chai';
|
|
import configureStore from 'redux-mock-store';
|
|
import { shallow } from 'enzyme';
|
|
import $ from 'jquery';
|
|
import sinon from 'sinon';
|
|
|
|
import DatasourceModal from '../../../src/datasource/DatasourceModal';
|
|
import DatasourceEditor from '../../../src/datasource/DatasourceEditor';
|
|
import mockDatasource from '../../fixtures/mockDatasource';
|
|
|
|
const props = {
|
|
datasource: mockDatasource['7__table'],
|
|
addSuccessToast: () => {},
|
|
addDangerToast: () => {},
|
|
onChange: sinon.spy(),
|
|
show: true,
|
|
onHide: () => {},
|
|
};
|
|
|
|
describe('DatasourceModal', () => {
|
|
const mockStore = configureStore([]);
|
|
const store = mockStore({});
|
|
|
|
let wrapper;
|
|
let el;
|
|
let ajaxStub;
|
|
let inst;
|
|
|
|
beforeEach(() => {
|
|
ajaxStub = sinon.stub($, 'ajax');
|
|
el = <DatasourceModal {...props} />;
|
|
wrapper = shallow(el, { context: { store } }).dive();
|
|
inst = wrapper.instance();
|
|
});
|
|
|
|
afterEach(() => {
|
|
ajaxStub.restore();
|
|
});
|
|
|
|
it('is valid', () => {
|
|
expect(React.isValidElement(el)).to.equal(true);
|
|
});
|
|
|
|
it('renders a Modal', () => {
|
|
expect(wrapper.find(Modal)).to.have.lengthOf(1);
|
|
});
|
|
|
|
it('renders a DatasourceEditor', () => {
|
|
expect(wrapper.find(DatasourceEditor)).to.have.lengthOf(1);
|
|
});
|
|
|
|
it('saves on confirm', () => {
|
|
inst.onConfirmSave();
|
|
expect(ajaxStub.calledOnce).to.equal(true);
|
|
});
|
|
});
|