More Dashboard UX unit tests (#1603)

This commit is contained in:
Maxime Beauchemin 2016-11-17 10:05:08 -08:00 committed by GitHub
parent 4f7f437527
commit c362f2869e
6 changed files with 66 additions and 7 deletions

2
.gitignore vendored
View File

@ -1,4 +1,6 @@
*.pyc
yarn-error.log
_modules
superset/assets/coverage/*
changelog.sh
.DS_Store

View File

@ -74,7 +74,7 @@ function initDashboardView(dashboard) {
$('[data-toggle="tooltip"]').tooltip({ container: 'body' });
}
function dashboardContainer(dashboard) {
export function dashboardContainer(dashboard) {
return Object.assign({}, dashboard, {
type: 'dashboard',
filters: {},

View File

@ -10,14 +10,9 @@ import CodeModal from './CodeModal';
import SliceAdder from './SliceAdder';
const propTypes = {
table: React.PropTypes.object,
dashboard: React.PropTypes.object.isRequired,
};
const defaultProps = {
actions: {},
};
class Controls extends React.PureComponent {
constructor(props) {
super(props);
@ -138,6 +133,5 @@ class Controls extends React.PureComponent {
}
}
Controls.propTypes = propTypes;
Controls.defaultProps = defaultProps;
export default Controls;

View File

@ -0,0 +1,21 @@
import React from 'react';
import CodeModal from '../../../javascripts/dashboard/components/CodeModal';
import { mount } from 'enzyme';
import { describe, it } from 'mocha';
import { expect } from 'chai';
describe('CodeModal', () => {
const mockedProps = {
triggerNode: <i className="fa fa-edit" />,
};
it('is valid', () => {
expect(
React.isValidElement(<CodeModal {...mockedProps} />)
).to.equal(true);
});
it('renders the trigger node', () => {
const wrapper = mount(<CodeModal {...mockedProps} />);
expect(wrapper.find('.fa-edit')).to.have.length(1);
});
});

View File

@ -0,0 +1,21 @@
import React from 'react';
import CssEditor from '../../../javascripts/dashboard/components/CssEditor';
import { mount } from 'enzyme';
import { describe, it } from 'mocha';
import { expect } from 'chai';
describe('CssEditor', () => {
const mockedProps = {
triggerNode: <i className="fa fa-edit" />,
};
it('is valid', () => {
expect(
React.isValidElement(<CssEditor {...mockedProps} />)
).to.equal(true);
});
it('renders the trigger node', () => {
const wrapper = mount(<CssEditor {...mockedProps} />);
expect(wrapper.find('.fa-edit')).to.have.length(1);
});
});

View File

@ -0,0 +1,21 @@
import React from 'react';
import RefreshIntervalModal from '../../../javascripts/dashboard/components/RefreshIntervalModal';
import { mount } from 'enzyme';
import { describe, it } from 'mocha';
import { expect } from 'chai';
describe('RefreshIntervalModal', () => {
const mockedProps = {
triggerNode: <i className="fa fa-edit" />,
};
it('is valid', () => {
expect(
React.isValidElement(<RefreshIntervalModal {...mockedProps} />)
).to.equal(true);
});
it('renders the trigger node', () => {
const wrapper = mount(<RefreshIntervalModal {...mockedProps} />);
expect(wrapper.find('.fa-edit')).to.have.length(1);
});
});