import React from 'react';
import { shallow, mount } from 'enzyme';
import sinon from 'sinon';
import Button from '../';
describe('Button test', () => {
it('create', () => {
const w = shallow(
);
expect(w.hasClass('el-button--primary')).toBeTruthy();
expect(w.childAt(0).text()).toBe('TEST');
});
it('icon', () => {
const w = shallow(
);
expect(w.childAt(0).hasClass('el-icon-search')).toBeTruthy();
});
it('nativeType', () => {
const w = shallow(
);
expect(w.prop('type')).toBe('submit');
});
it('loading', () => {
const w = shallow(
);
expect(w.hasClass('is-loading')).toBeTruthy();
expect(w.childAt(0).hasClass('el-icon-loading')).toBeTruthy();
});
it('disabled', () => {
const w = shallow(
);
expect(w.hasClass('is-disabled')).toBeTruthy();
});
it('size', () => {
const w = shallow(
);
expect(w.hasClass('el-button--large')).toBeTruthy();
});
it('plain', () => {
const w = shallow(
);
expect(w.hasClass('is-plain')).toBeTruthy();
});
it('click', () => {
const fn = sinon.spy();
const w = shallow(
);
w.simulate('click');
expect(fn.callCount).toBe(1);
});
});