|
| 1 | +import React from 'react'; |
| 2 | +import { Circle, Line } from '../src'; |
| 3 | +import { render, waitFor } from '@testing-library/react'; |
| 4 | + |
| 5 | +describe('(Circle | Line).indeterminate', () => { |
| 6 | + describe('Line', () => { |
| 7 | + it('should render indeterminate style', () => { |
| 8 | + const { container, rerender } = render(<Line loading />); |
| 9 | + const line: HTMLElement = container.querySelector('.rc-progress-line-path'); |
| 10 | + |
| 11 | + expect(line.style.animation).toContain('indeterminate-animate'); |
| 12 | + |
| 13 | + rerender(<Line />); |
| 14 | + |
| 15 | + expect(line.style.animation).not.toContain('indeterminate-animate'); |
| 16 | + }); |
| 17 | + |
| 18 | + it('should render indeterminate with percent and rerennder without it', () => { |
| 19 | + const { container, rerender } = render(<Line percent={20} loading />); |
| 20 | + const line: HTMLElement = container.querySelector('.rc-progress-line-path'); |
| 21 | + |
| 22 | + expect(line.style.animation).toContain('indeterminate-animate'); |
| 23 | + expect(line.style.strokeDasharray).toEqual('20 100'); |
| 24 | + |
| 25 | + rerender(<Line percent={20} />); |
| 26 | + |
| 27 | + expect(line.style.animation).not.toContain('indeterminate-animate'); |
| 28 | + expect(line.style.strokeDasharray).not.toEqual('20 100'); |
| 29 | + }); |
| 30 | + }); |
| 31 | + |
| 32 | + describe('Circle', () => { |
| 33 | + it('should render indeterminate style', () => { |
| 34 | + const { container, rerender } = render(<Circle loading />); |
| 35 | + const circle: HTMLElement = container.querySelector('.rc-progress-circle-path'); |
| 36 | + |
| 37 | + expect(circle.style.animation).toContain('indeterminate-animate'); |
| 38 | + |
| 39 | + rerender(<Circle />); |
| 40 | + |
| 41 | + expect(circle.style.animation).not.toContain('indeterminate-animate'); |
| 42 | + }); |
| 43 | + |
| 44 | + it('should rerender indeterminate with percent Circle', () => { |
| 45 | + const { container, rerender } = render(<Circle percent={20} loading />); |
| 46 | + const circle: HTMLElement = container.querySelector('.rc-progress-circle-path'); |
| 47 | + |
| 48 | + expect(circle.style.animation).toContain('indeterminate-animate'); |
| 49 | + expect(circle.style.transform).toEqual('rotate(0deg)'); |
| 50 | + |
| 51 | + rerender(<Circle percent={20} />); |
| 52 | + |
| 53 | + expect(circle.style.animation).not.toContain('indeterminate-animate'); |
| 54 | + expect(circle.style.transform).not.toEqual('rotate(0deg)'); |
| 55 | + }); |
| 56 | + }); |
| 57 | +}); |
0 commit comments