1 | import React from 'react';
|
2 | import { render, cleanup } from '@testing-library/react';
|
3 | import MockUpload from './mockUpload';
|
4 | import { UploadProgressBar } from '..';
|
5 |
|
6 | const instance = new MockUpload();
|
7 |
|
8 | describe('UploadProgressBar', () => {
|
9 | afterEach(() => {
|
10 | instance.reset();
|
11 | cleanup();
|
12 | jest.clearAllMocks();
|
13 | });
|
14 | test('should render', () => {
|
15 | render(<UploadProgressBar upload={instance} />);
|
16 | });
|
17 |
|
18 | test('should render progress', () => {
|
19 | const { getByTestId } = render(<UploadProgressBar upload={instance} />);
|
20 | instance.progress(50);
|
21 |
|
22 | getByTestId('upload-progress');
|
23 | });
|
24 |
|
25 | test('should render success', () => {
|
26 | const { getByTestId } = render(<UploadProgressBar upload={instance} />);
|
27 | instance.success();
|
28 |
|
29 | const progressBar = getByTestId('upload-progress');
|
30 |
|
31 | expect(progressBar.className).toContain('progress-complete');
|
32 | });
|
33 |
|
34 | test('should render error', () => {
|
35 | const { getByTestId } = render(<UploadProgressBar upload={instance} />);
|
36 | instance.error('File upload rejected');
|
37 |
|
38 | getByTestId('upload-error-message');
|
39 | });
|
40 |
|
41 | test('should render password verification button', () => {
|
42 | const { getByTestId } = render(<UploadProgressBar upload={instance} />);
|
43 | instance.error('Encrypted files require a password', 'encrypted');
|
44 |
|
45 | getByTestId('password-form-encrypted');
|
46 | });
|
47 |
|
48 | // 1 Test for striped and animated
|
49 | // striped
|
50 | // animated
|
51 |
|
52 | test('should render striped', () => {
|
53 | const { getByTestId } = render(
|
54 | <UploadProgressBar upload={instance} striped />
|
55 | );
|
56 |
|
57 | const progressBar = getByTestId('progress-inner');
|
58 |
|
59 | expect(progressBar.className).toContain('progress-bar-striped');
|
60 | });
|
61 |
|
62 | test('should render animated', () => {
|
63 | const { getByTestId } = render(
|
64 | <UploadProgressBar upload={instance} animated />
|
65 | );
|
66 |
|
67 | const progressBar = getByTestId('progress-inner');
|
68 |
|
69 | expect(progressBar.className).toContain('progress-bar-animated');
|
70 | });
|
71 |
|
72 | test('should render striped and animated', () => {
|
73 | const { getByTestId } = render(
|
74 | <UploadProgressBar upload={instance} striped animated />
|
75 | );
|
76 |
|
77 | const progressBar = getByTestId('progress-inner');
|
78 |
|
79 | expect(progressBar.className).toContain('animated');
|
80 | expect(progressBar.className).toContain('striped');
|
81 | });
|
82 | });
|