Skip to content

Commit

Permalink
apply suggested renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Esteban Beltran committed Feb 16, 2022
1 parent 9cf248d commit 8b159d2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { CreateCaseFlyoutProps } from '../create/flyout';

export const initialCasesContextState = (): CasesContextState => {
export const getInitialCasesContextState = (): CasesContextState => {
return {
createCaseFlyout: {
isFlyoutOpen: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import React from 'react';
import { AppMockRenderer, createAppMockRenderer } from '../../common/mock';
import { getCreateCaseFlyoutLazyNoProvider } from '../../methods/get_create_case_flyout';
import { CasesContextUI } from './cases_context_ui';
import { CasesGlobalComponents } from './cases_global_components';

jest.mock('../../methods/get_create_case_flyout');

Expand All @@ -32,7 +32,7 @@ describe('Cases context UI', () => {
},
},
};
appMock.render(<CasesContextUI state={state} />);
appMock.render(<CasesGlobalComponents state={state} />);
expect(getCreateCaseFlyoutLazyNoProviderMock).toHaveBeenCalledWith({ attachments: [] });
});
it('should not render the create case flyout when isFlyoutOpen is true', async () => {
Expand All @@ -41,7 +41,7 @@ describe('Cases context UI', () => {
isFlyoutOpen: false,
},
};
appMock.render(<CasesContextUI state={state} />);
appMock.render(<CasesGlobalComponents state={state} />);
expect(getCreateCaseFlyoutLazyNoProviderMock).not.toHaveBeenCalled();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React from 'react';
import { getCreateCaseFlyoutLazyNoProvider } from '../../methods';
import { CasesContextState } from './cases_context_reducer';

export const CasesContextUI = React.memo(({ state }: { state: CasesContextState }) => {
export const CasesGlobalComponents = React.memo(({ state }: { state: CasesContextState }) => {
return (
<>
{state.createCaseFlyout.isFlyoutOpen && state.createCaseFlyout.props !== undefined
Expand All @@ -18,4 +18,4 @@ export const CasesContextUI = React.memo(({ state }: { state: CasesContextState
</>
);
});
CasesContextUI.displayName = 'CasesContextUi';
CasesGlobalComponents.displayName = 'CasesContextUi';
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import { useApplication } from './use_application';
import {
CasesContextStoreAction,
casesContextReducer,
initialCasesContextState,
getInitialCasesContextState,
} from './cases_context_reducer';
import { CasesContextFeatures, CasesFeatures } from '../../containers/types';
import { CasesContextUI } from './cases_context_ui';
import { CasesGlobalComponents } from './cases_global_components';

export interface CasesContextValue {
owner: string[];
Expand Down Expand Up @@ -45,7 +45,7 @@ export const CasesProvider: React.FC<{ value: CasesContextProps }> = ({
value: { owner, userCanCrud, basePath = DEFAULT_BASE_PATH, features = {} },
}) => {
const { appId, appTitle } = useApplication();
const [state, dispatch] = useReducer(casesContextReducer, initialCasesContextState());
const [state, dispatch] = useReducer(casesContextReducer, getInitialCasesContextState());
const [value, setValue] = useState<CasesContextStateValue>(() => ({
owner,
userCanCrud,
Expand Down Expand Up @@ -76,7 +76,7 @@ export const CasesProvider: React.FC<{ value: CasesContextProps }> = ({

return isCasesContextValue(value) ? (
<CasesContext.Provider value={value}>
<CasesContextUI state={state} />
<CasesGlobalComponents state={state} />
{children}
</CasesContext.Provider>
) : null;
Expand Down

0 comments on commit 8b159d2

Please sign in to comment.