Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

psp-7962 correct missing no rows message introduced by operation sect… #3894

Merged
merged 4 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import { lookupCodesSlice } from '@/store/slices/lookupCodes';
import { createMemoryHistory } from 'history';
import { mockLookups } from '@/mocks/lookups.mock';
import { render, RenderOptions } from '@/utils/test-utils';
import { EpochIsoDateTime } from '@/models/api/UtcIsoDateTime';
import { getEmptyProperty } from '@/models/defaultInitializers';
import { ApiGen_Concepts_Property } from '@/models/api/generated/ApiGen_Concepts_Property';
import { ApiGen_CodeTypes_PropertyOperationTypes } from '@/models/api/generated/ApiGen_CodeTypes_PropertyOperationTypes';
import {
IOperationSectionViewProps,
OperationSectionView,
} from './propertyOperation/OperationSectionView';
import { OperationSet } from './propertyOperation/OperationContainer';
import { getMockApiProperties } from '@/mocks/properties.mock';

const history = createMemoryHistory();
const store = { [lookupCodesSlice.name]: { lookupCodes: mockLookups } };

describe('Operation section view', () => {
const setup = (
renderOptions: RenderOptions & { props?: Partial<IOperationSectionViewProps> } = {},
) => {
const props = renderOptions.props;
const component = render(
<OperationSectionView
subdivisionOperations={props?.subdivisionOperations ?? []}
consolidationOperations={props?.consolidationOperations ?? []}
loading={props?.loading ?? false}
/>,
{
...renderOptions,
useMockAuthentication: true,
claims: renderOptions?.claims,
history: history,
store: store,
},
);

return { ...component };
};

it('matches snapshot', () => {
const subdivisionOperations: OperationSet[] = [
{
sourceProperties: [getMockApiProperties()[0]],
destinationProperties: [getMockApiProperties()[1]],
operationDateTime: '2020-01-01',
operationType: ApiGen_CodeTypes_PropertyOperationTypes.SUBDIVIDE,
},
];
const consolidationOperations: OperationSet[] = [
{
sourceProperties: [getMockApiProperties()[0]],
destinationProperties: [getMockApiProperties()[1]],
operationDateTime: '2020-01-01',
operationType: ApiGen_CodeTypes_PropertyOperationTypes.CONSOLIDATE,
},
];
const { asFragment } = setup({ props: { subdivisionOperations, consolidationOperations } });
expect(asFragment()).toMatchSnapshot();
});

it('Displays the empty subdivisions message', async () => {
const subdivisionOperations: OperationSet[] = [
{
sourceProperties: [],
destinationProperties: [],
operationDateTime: '2020-01-01',
operationType: ApiGen_CodeTypes_PropertyOperationTypes.SUBDIVIDE,
},
];
const consolidationOperations: OperationSet[] = [
{
sourceProperties: [getMockApiProperties()[0]],
destinationProperties: [getMockApiProperties()[1]],
operationDateTime: '2020-01-01',
operationType: ApiGen_CodeTypes_PropertyOperationTypes.CONSOLIDATE,
},
];

const { getByText, container } = setup({
props: { subdivisionOperations, consolidationOperations },
});

expect(getByText('This property is not part of a subdivision')).toBeVisible();
});

it('Displays the empty consolidations message', async () => {
const subdivisionOperations: OperationSet[] = [
{
sourceProperties: [getMockApiProperties()[0]],
destinationProperties: [getMockApiProperties()[1]],
operationDateTime: '2020-01-01',
operationType: ApiGen_CodeTypes_PropertyOperationTypes.SUBDIVIDE,
},
];
const consolidationOperations: OperationSet[] = [
{
sourceProperties: [],
destinationProperties: [],
operationDateTime: '2020-01-01',
operationType: ApiGen_CodeTypes_PropertyOperationTypes.CONSOLIDATE,
},
];

const { getByText, container } = setup({
props: { subdivisionOperations, consolidationOperations },
});

expect(getByText('This property is not part of a consolidation')).toBeVisible();
});
});
Loading
Loading