Skip to content

Commit

Permalink
[7.x] [Enterprise Search] Misc test branch coverage (#86847) (#87202)
Browse files Browse the repository at this point in the history
* [Enterprise Search] Misc test branch coverage (#86847)

* Remove unnecessary || {} branch

schema is always required / should never be undefined

* Cover if (addFieldFormErrors) branch

* Increase coverage of determineTooltipContent by simplifying branching

- most of these checks aren't necessary due to early returns

* Cover branch in WS source_icon

Co-authored-by: Kibana Machine <[email protected]>

* Update x-pack/plugins/enterprise_search/public/applications/workplace_search/components/shared/source_icon/source_icon.test.tsx

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
Constance and kibanamachine authored Jan 4, 2021
1 parent 8b201aa commit ae2f5fa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@ export const buildSearchUIConfig = (apiConnector: object, schema: Schema) => {
sortField: 'id',
},
searchQuery: {
result_fields: Object.keys(schema || {}).reduce(
(acc: { [key: string]: object }, key: string) => {
acc[key] = {
snippet: {
size: 300,
fallback: true,
},
raw: {},
};
return acc;
},
{}
),
result_fields: Object.keys(schema).reduce((acc: { [key: string]: object }, key: string) => {
acc[key] = {
snippet: {
size: 300,
fallback: true,
},
raw: {},
};
return acc;
}, {}),
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,12 @@ export const determineTooltipContent = (
if (!logRetentionSettings.enabled) {
return renderOrReturnMessage(messages.noLogging);
}
if (logRetentionSettings.enabled && !ilmEnabled) {
if (!ilmEnabled) {
return renderOrReturnMessage(messages.ilmDisabled);
}
if (
logRetentionSettings.enabled &&
ilmEnabled &&
!logRetentionSettings.retentionPolicy?.isDefault
) {
if (!logRetentionSettings.retentionPolicy?.isDefault) {
return renderOrReturnMessage(messages.customPolicy);
}
if (
logRetentionSettings.enabled &&
ilmEnabled &&
logRetentionSettings.retentionPolicy?.isDefault
) {
} else {
return renderOrReturnMessage(messages.defaultPolicy);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ describe('SchemaAddFieldModal', () => {
expect(wrapper.find(EuiModal)).toHaveLength(1);
});

// No matter what I try I can't get this to actually achieve coverage.
it('sets loading state in useEffect', () => {
setState(true);
const wrapper = mount(<SchemaAddFieldModal {...props} {...errors} />);
const wrapper = mount(<SchemaAddFieldModal {...props} />);
wrapper.setProps({ ...errors });
const input = wrapper.find(EuiFieldText);

expect(input.prop('isLoading')).toEqual(false);
Expand Down

0 comments on commit ae2f5fa

Please sign in to comment.