prometheus
68 строк · 2.1 Кб
1import * as React from 'react';
2import { shallow } from 'enzyme';
3import { WALReplayData } from '../types/types';
4import { StartingContent } from './withStartingIndicator';
5import { Alert, Progress } from 'reactstrap';
6
7describe('Starting', () => {
8describe('progress bar', () => {
9it('does not show when replay not started', () => {
10const status: WALReplayData = {
11min: 0,
12max: 0,
13current: 0,
14};
15const starting = shallow(<StartingContent status={status} isUnexpected={false} />);
16const progress = starting.find(Progress);
17expect(progress).toHaveLength(0);
18});
19
20it('shows progress bar when max is not 0', () => {
21const status: WALReplayData = {
22min: 0,
23max: 1,
24current: 0,
25};
26const starting = shallow(<StartingContent status={status} isUnexpected={false} />);
27const progress = starting.find(Progress);
28expect(progress).toHaveLength(1);
29});
30
31it('renders progress correctly', () => {
32const status: WALReplayData = {
33min: 0,
34max: 20,
35current: 1,
36};
37const starting = shallow(<StartingContent status={status} isUnexpected={false} />);
38const progress = starting.find(Progress);
39expect(progress.prop('value')).toBe(2);
40expect(progress.prop('min')).toBe(0);
41expect(progress.prop('max')).toBe(21);
42});
43
44it('shows done when replay done', () => {
45const status: WALReplayData = {
46min: 0,
47max: 20,
48current: 20,
49};
50const starting = shallow(<StartingContent status={status} isUnexpected={false} />);
51const progress = starting.find(Progress);
52expect(progress.prop('value')).toBe(21);
53expect(progress.prop('color')).toBe('success');
54});
55
56it('shows unexpected error', () => {
57const status: WALReplayData = {
58min: 0,
59max: 20,
60current: 0,
61};
62
63const starting = shallow(<StartingContent status={status} isUnexpected={true} />);
64const alert = starting.find(Alert);
65expect(alert.prop('color')).toBe('danger');
66});
67});
68});
69