Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

QA: Button loading prop as object feature #19213

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions components/button/__tests__/index.test.js
@@ -1,11 +1,13 @@
import React, { Component } from 'react';
import { render, mount } from 'enzyme';
import { render, mount, shallow } from 'enzyme';
import renderer from 'react-test-renderer';
import Button from '..';
import Icon from '../../icon';
import mountTest from '../../../tests/shared/mountTest';
import { sleep } from '../../../tests/utils';

jest.useFakeTimers();

describe('Button', () => {
mountTest(Button);
mountTest(() => <Button size="large" />);
Expand Down Expand Up @@ -129,7 +131,7 @@ describe('Button', () => {
expect(wrapper.find('.ant-btn-loading').length).toBe(1);
});

it('should change loading state with delay', () => {
fit('should change loading state with delay', () => {
// eslint-disable-next-line
class DefaultButton extends Component {
state = {
Expand All @@ -142,6 +144,7 @@ describe('Button', () => {

render() {
const { loading } = this.state;
console.log(loading);
return (
<Button loading={loading} onClick={this.enterLoading}>
Button
Expand All @@ -150,8 +153,11 @@ describe('Button', () => {
}
}
const wrapper = mount(<DefaultButton />);
expect(wrapper.render().hasClass('ant-btn-loading')).toBe(false);
wrapper.simulate('click');
expect(wrapper.hasClass('ant-btn-loading')).toBe(false);
expect(wrapper.render().hasClass('ant-btn-loading')).toBe(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be false because we have a delayed loading. I think our loading prop of object type works correctly.

jest.runOnlyPendingTimers();
expect(wrapper.render().hasClass('ant-btn-loading')).toBe(false);
});

it('should not clickable when button is loading', () => {
Expand Down