easier tab closing in sqllab (#4738)

This commit is contained in:
Gabe Lyons
2018-04-02 14:59:08 -07:00
committed by Grace Guo
parent 11c9e67ebb
commit e0f541f486
4 changed files with 85 additions and 1 deletions

View File

@@ -0,0 +1,35 @@
import React from 'react';
import sinon from 'sinon';
import { expect } from 'chai';
import { describe, it } from 'mocha';
import { shallow } from 'enzyme';
import TabStatusIcon from '../../../javascripts/SqlLab/components/TabStatusIcon';
function setup() {
const onClose = sinon.spy();
const wrapper = shallow(<TabStatusIcon onClose={onClose} tabState="running" />);
return { wrapper, onClose };
}
describe('TabStatusIcon', () => {
it('renders a circle without an x when hovered', () => {
const { wrapper } = setup();
expect(wrapper.find('div.circle')).to.have.length(1);
expect(wrapper.text()).to.equal('');
});
it('renders a circle with an x when hovered', () => {
const { wrapper } = setup();
wrapper.simulate('mouseOver');
expect(wrapper.find('div.circle')).to.have.length(1);
expect(wrapper.text()).to.equal('×');
});
it('calls onClose from props when clicked', () => {
const { wrapper, onClose } = setup();
wrapper.simulate('click');
// eslint-disable-next-line no-unused-expressions
expect(onClose.calledOnce).to.be.true;
});
});