Skip to content

Commit

Permalink
Refactor WS test to match AS
Browse files Browse the repository at this point in the history
There was an issue where 100% test coverage was not achieved in Workplace Search. This had already been fixed in App Search by refactoring. This changes the code and test in Workplace Search to match
  • Loading branch information
scottybollinger committed Jun 14, 2021
1 parent 4dccd34 commit cc97d98
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,6 @@ describe('RoleMappingsLogic', () => {

expect(RoleMappingsLogic.values.selectedAuthProviders).toEqual([providers[1]]);
});

it('handles catch-all state', () => {
RoleMappingsLogic.actions.handleAuthProviderChange(providerWithAny);

expect(RoleMappingsLogic.values.selectedAuthProviders).toEqual([ANY_AUTH_PROVIDER]);
});
});

it('resetState', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,12 @@ export const RoleMappingsLogic = kea<MakeLogicType<RoleMappingsValues, RoleMappi
handleAuthProviderChange: (previous, { value }) => {
const previouslyContainedAny = previous.includes(ANY_AUTH_PROVIDER);
const newSelectionsContainAny = value.includes(ANY_AUTH_PROVIDER);
const hasItems = value.length > 0;

if (value.length < 1) return [ANY_AUTH_PROVIDER];
if (value.length === 1) return value;
if (!newSelectionsContainAny) return value;
if (previouslyContainedAny) return value.filter((v) => v !== ANY_AUTH_PROVIDER);
if (!newSelectionsContainAny && hasItems) return value;
if (previouslyContainedAny && hasItems)
return value.filter((v) => v !== ANY_AUTH_PROVIDER);
return [ANY_AUTH_PROVIDER];
},
setRoleMapping: (_, { roleMapping }) => roleMapping.authProvider,
Expand Down

0 comments on commit cc97d98

Please sign in to comment.