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

Remove UPDATE_CONTEXTUAL_ENTITIES_OPTIONS action #50

Merged
merged 2 commits into from
Apr 18, 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
8 changes: 0 additions & 8 deletions @types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ declare namespace EntitiesSearch {
> extends Readonly<{
entities: Entities<E>;
kind: Kind<K>;
contextualEntitiesOptions: OptionSet;
currentEntitiesOptions: OptionSet;
selectedEntitiesOptions: OptionSet;
searchPhrase: string;
Expand All @@ -139,13 +138,6 @@ declare namespace EntitiesSearch {
K
>['currentEntitiesOptions'];
}
| {
type: 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS';
contextualEntitiesOptions: EntitiesState<
E,
K
>['contextualEntitiesOptions'];
}
| {
type: 'UPDATE_SELECTED_ENTITIES_OPTIONS';
selectedEntitiesOptions: EntitiesState<
Expand Down
4 changes: 0 additions & 4 deletions sources/client/src/hooks/use-entities-options-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ export function useEntitiesOptionsStorage< E, K >(
type: 'UPDATE_SELECTED_ENTITIES_OPTIONS',
selectedEntitiesOptions,
} );
dispatch( {
type: 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS',
contextualEntitiesOptions: currentEntitiesOptions,
} );
dispatch( {
type: 'UPDATE_CURRENT_ENTITIES_OPTIONS',
currentEntitiesOptions,
Expand Down
1 change: 0 additions & 1 deletion sources/client/src/storage/entities/initial-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export function makeInitialState< E, K >(
return {
entities: new Set< E >( [] ),
kind: new Set< K >( [] ),
contextualEntitiesOptions: new Set< Options< E > >(),
currentEntitiesOptions: new Set< Options< E > >(),
selectedEntitiesOptions: new Set< Options< E > >(),
searchPhrase: '',
Expand Down
8 changes: 0 additions & 8 deletions sources/client/src/storage/entities/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ export function reducer< E, K >(
kind: action.kind,
};

case 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS':
return {
...state,
contextualEntitiesOptions: action.contextualEntitiesOptions,
};

case 'UPDATE_CURRENT_ENTITIES_OPTIONS':
return {
...state,
Expand All @@ -56,14 +50,12 @@ export function reducer< E, K >(
return {
...state,
selectedEntitiesOptions: new Set(),
contextualEntitiesOptions: new Set(),
currentEntitiesOptions: new Set(),
};

case 'UPDATE_ENTITIES_OPTIONS_FOR_NEW_KIND':
return {
...state,
contextualEntitiesOptions: action.entitiesOptions,
currentEntitiesOptions: action.entitiesOptions,
selectedEntitiesOptions: new Set(),
entities: new Set(),
Expand Down
8 changes: 0 additions & 8 deletions tests/client/unit/hooks/use-entities-options-storage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ describe( 'Use Posts Options Storage', () => {
type: 'UPDATE_SELECTED_ENTITIES_OPTIONS',
selectedEntitiesOptions,
} );
expect( dispatch ).toHaveBeenCalledWith( {
type: 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS',
contextualEntitiesOptions: currentEntitiesOptions,
} );
expect( dispatch ).toHaveBeenCalledWith( {
type: 'UPDATE_CURRENT_ENTITIES_OPTIONS',
currentEntitiesOptions,
Expand Down Expand Up @@ -175,10 +171,6 @@ describe( 'Use Posts Options Storage', () => {
type: 'UPDATE_SELECTED_ENTITIES_OPTIONS',
selectedEntitiesOptions: expectedSet,
} );
expect( dispatch ).toHaveBeenCalledWith( {
type: 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS',
contextualEntitiesOptions: expectedSet,
} );
expect( dispatch ).toHaveBeenCalledWith( {
type: 'UPDATE_CURRENT_ENTITIES_OPTIONS',
currentEntitiesOptions: expectedSet,
Expand Down
1 change: 0 additions & 1 deletion tests/client/unit/storage/initial-state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { makeInitialState } from '../../../../sources/client/src/storage/entitie
describe( 'Initial state', () => {
it( 'ensure all options are empty', () => {
const initialState = makeInitialState( {} );
expect( initialState.contextualEntitiesOptions.length() ).toBe( 0 );
expect( initialState.currentEntitiesOptions.length() ).toBe( 0 );
expect( initialState.selectedEntitiesOptions.length() ).toBe( 0 );
} );
Expand Down
23 changes: 0 additions & 23 deletions tests/client/unit/storage/reducer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,6 @@ describe( 'reducer', () => {
expect( newState.kind ).toEqual( kind );
} );

it( 'Update the Contextual Posts Options', () => {
const contextualPostsOptions = new Set( [
{
value: faker.number.int( 10 ),
label: 'Post One',
},
{
value: faker.number.int( { min: 11, max: 20 } ),
label: 'Post Two',
},
] );
const newState = reducer( state, {
type: 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS',
contextualEntitiesOptions: contextualPostsOptions,
} );

expect( newState.contextualEntitiesOptions ).toEqual(
contextualPostsOptions
);
} );

it( 'Update the Posts Options', () => {
const postsOptions = new Set( [
{
Expand Down Expand Up @@ -120,7 +99,6 @@ describe( 'reducer', () => {
} );

expect( newState.selectedEntitiesOptions ).toEqual( new Set() );
expect( newState.contextualEntitiesOptions ).toEqual( new Set() );
expect( newState.currentEntitiesOptions ).toEqual( new Set() );
} );

Expand All @@ -142,7 +120,6 @@ describe( 'reducer', () => {
entitiesOptions,
} );

expect( newState.contextualEntitiesOptions ).toEqual( entitiesOptions );
expect( newState.currentEntitiesOptions ).toEqual( entitiesOptions );
expect( newState.selectedEntitiesOptions ).toEqual( new Set() );
expect( newState.entities ).toEqual( new Set() );
Expand Down
Loading