import { configure, mount, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import * as React from 'react';
import { Animated } from 'react-native';
import renderer from 'react-test-renderer';
import MDProgress from '../index';
configure({ adapter: new Adapter() });
beforeEach(() => {
jest.useFakeTimers();
});
it('renders correctly with defaults', () => {
const component = renderer.create().toJSON();
expect(component).toMatchSnapshot();
});
it('renders correctly with not animation', () => {
const component = renderer
.create()
.toJSON();
expect(component).toMatchSnapshot();
});
it('renders correctly with animation', () => {
const component = renderer
.create()
.toJSON();
expect(component).toMatchSnapshot();
});
it('renders correctly with animation', () => {
const component = shallow(
);
component.setProps({ progress: 0.7, isAnimate: true });
jest.runOnlyPendingTimers();
jest.advanceTimersByTime(300);
const b: any = component.state('curProgress');
expect(b._value).toEqual(0.7);
jest.useRealTimers();
});
it('renders correctly with set state', () => {
const component = shallow(
);
component.setProps({ progress: 0.7, isAnimate: false });
expect(component.state('curProgress')).toEqual(new Animated.Value(0.7));
});