Skip to content

Commit

Permalink
[ML] Fix jest tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Mar 29, 2021
1 parent cbba256 commit 976d5ba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/ml/common/util/object_utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ describe('object_utils', () => {
'attribute1',
'otherAttribute',
])
).toBe(true);
).toBe(false);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ interface Response {

export function filterRuntimeMappings(job: Job, datafeed: Datafeed): Response {
if (
datafeed.runtime_mappings === undefined ||
isPopulatedObject(datafeed.runtime_mappings) === false
!(
isPopulatedObject(datafeed, ['runtime_mappings']) &&
isPopulatedObject(datafeed.runtime_mappings)
)
) {
return {
runtime_mappings: {},
Expand Down Expand Up @@ -83,13 +85,10 @@ function findFieldsInJob(job: Job, datafeed: Datafeed) {
return [...usedFields];
}

function findFieldsInAgg(obj: Record<string, object>) {
function findFieldsInAgg(obj: Record<string, unknown>) {
const fields: string[] = [];
Object.entries(obj).forEach(([key, val]) => {
if (
isPopulatedObject<Record<string, object>>(val) &&
Object.keys(val).every((d) => typeof d === 'object')
) {
if (isPopulatedObject(val)) {
fields.push(...findFieldsInAgg(val));
} else if (typeof val === 'string' && key === 'field') {
fields.push(val);
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/transform/common/utils/object_utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ describe('object_utils', () => {
'attribute1',
'otherAttribute',
])
).toBe(true);
).toBe(false);
});
});

0 comments on commit 976d5ba

Please sign in to comment.