-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
psp-7962 correct missing no rows message introduced by operation sect… (
#3894) * psp-7962 correct missing no rows message introduced by operation section subtable. * snapshot update. * test corrections. --------- Co-authored-by: Alejandro Sanchez <[email protected]>
- Loading branch information
1 parent
183813b
commit 70348e3
Showing
4 changed files
with
1,018 additions
and
25 deletions.
There are no files selected for viewing
112 changes: 112 additions & 0 deletions
112
...rc/features/mapSideBar/property/tabs/propertyDetails/detail/OperationSectionView.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
Oops, something went wrong.