Skip to content

Commit

Permalink
MNT Update unit tests for archive text
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Aug 8, 2023
1 parent 17924b8 commit 21483f1
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ BulkDeleteConfirmation.propTypes = {
onCancel: PropTypes.func.isRequired,
onModalClose: PropTypes.func.isRequired,
onConfirm: PropTypes.func.isRequired,
archiveFiles: PropTypes.bool.isRequired,
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ DeletionModal.propTypes = {
handler: PropTypes.func,
color: PropTypes.string
})),
archiveFiles: PropTypes.bool.isRequired,
};

export default DeletionModal;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
import { Component } from '../BulkDeleteConfirmation';
import ShallowRenderer from 'react-test-renderer/shallow';

describe('BulkDeleteMessage', () => {
describe('BulkDeleteConfirmation', () => {
const renderer = new ShallowRenderer();

const FOLDER = 'folder';
Expand All @@ -28,10 +28,11 @@ describe('BulkDeleteMessage', () => {
onCancel: jest.fn(),
onModalClose: jest.fn(),
onConfirm: jest.fn(),
archiveFiles: false
};
});

it('Nothing in use', () => {
it('Nothing in use - delete', () => {
renderer.render(<Component {...props} files={files.slice(0, 2)} />);
const { props: { isOpen, actions } } = renderer.getRenderOutput();

Expand All @@ -45,20 +46,46 @@ describe('BulkDeleteMessage', () => {
expect(props.onCancel.mock.calls.length).toBe(0);
});

it('Folder in use', () => {
it('Nothing in use - archive', () => {
renderer.render(<Component
{...{
...props,
archiveFiles: true
}}
files={files.slice(0, 2)}
/>);
const { props: { actions } } = renderer.getRenderOutput();
expect(actions[0].label).toBe('Archive');
});

it('Folder in use - delete', () => {
renderer.render(<Component {...props} files={files} fileUsage={{ 1: 5 }} />);
const { props: { isOpen, actions } } = renderer.getRenderOutput();

expect(isOpen).toBe(true);
expect(actions.length).toBe(2);
expect(actions[0].label).toBe('Cancel');
expect(actions[1].label).toBe('Delete');

actions[0].handler();
expect(props.onConfirm.mock.calls.length).toBe(0);
expect(props.onCancel.mock.calls.length).toBe(1);
});

it('Files in use', () => {
it('Folder in use - archive', () => {
renderer.render(<Component
{...{
...props,
archiveFiles: true
}}
files={files}
fileUsage={{ 1: 5 }}
/>);
const { props: { actions } } = renderer.getRenderOutput();
expect(actions[1].label).toBe('Archive');
});

it('Files in use - delete', () => {
renderer.render(<Component {...props} files={files} fileUsage={{ 3: 5 }} />);
const { props: { isOpen, actions } } = renderer.getRenderOutput();

Expand All @@ -71,4 +98,17 @@ describe('BulkDeleteMessage', () => {
expect(props.onConfirm.mock.calls.length).toBe(0);
expect(props.onCancel.mock.calls.length).toBe(1);
});

it('Files in use - archive', () => {
renderer.render(<Component
{...{
...props,
archiveFiles: true
}}
files={files}
fileUsage={{ 3: 5 }}
/>);
const { props: { actions } } = renderer.getRenderOutput();
expect(actions[1].label).toBe('Archive');
});
});

0 comments on commit 21483f1

Please sign in to comment.