From 5bece64acc7920fec016ae9804f23d2d4f730f8e Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Mon, 7 Feb 2022 18:01:25 +0000 Subject: [PATCH] updating test checks --- .../ml/results/get_category_definition.ts | 40 ++++++++++++------- .../apis/ml/results/get_category_examples.ts | 34 +++++++--------- 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/x-pack/test/api_integration/apis/ml/results/get_category_definition.ts b/x-pack/test/api_integration/apis/ml/results/get_category_definition.ts index 6bcc581549251..78e3853abad85 100644 --- a/x-pack/test/api_integration/apis/ml/results/get_category_definition.ts +++ b/x-pack/test/api_integration/apis/ml/results/get_category_definition.ts @@ -115,22 +115,26 @@ export default ({ getService }: FtrProviderContext) => { idSpace1 ); - expect(resp).to.eql( - expectedCategoryDefinition, - `response should be ${JSON.stringify(expectedCategoryDefinition)} (got ${JSON.stringify( - resp - )})` + expect(resp.categoryId).to.eql( + expectedCategoryDefinition.categoryId, + `categoryId should be ${expectedCategoryDefinition.categoryId} (got ${resp.categoryId})` + ); + expect(resp.examples.length).to.eql( + expectedCategoryDefinition.examples.length, + `examples list length should be ${expectedCategoryDefinition.examples.length} (got ${resp.examples.length})` + ); + expect(resp.terms.length).to.be.greaterThan( + 0, + `terms string length should be greater than 0 (got ${resp.terms.length})` ); }); it('should not produce the correct category for the job', async () => { const resp = await getCategoryDefinition(jobIdSpace1, '2', USER.ML_POWERUSER, 200, idSpace1); - expect(resp).to.not.eql( - expectedCategoryDefinition, - `response should not be ${JSON.stringify(expectedCategoryDefinition)} (got ${JSON.stringify( - resp - )})` + expect(resp.categoryId).to.not.eql( + expectedCategoryDefinition.categoryId, + `categoryId should not be ${expectedCategoryDefinition.categoryId} (got ${resp.categoryId})` ); }); @@ -153,11 +157,17 @@ export default ({ getService }: FtrProviderContext) => { idSpace1 ); - expect(resp).to.eql( - expectedCategoryDefinition, - `response should be ${JSON.stringify(expectedCategoryDefinition)} (got ${JSON.stringify( - resp - )})` + expect(resp.categoryId).to.eql( + expectedCategoryDefinition.categoryId, + `categoryId should be ${expectedCategoryDefinition.categoryId} (got ${resp.categoryId})` + ); + expect(resp.examples.length).to.eql( + expectedCategoryDefinition.examples.length, + `examples list length should be ${expectedCategoryDefinition.examples.length} (got ${resp.examples.length})` + ); + expect(resp.terms.length).to.be.greaterThan( + 0, + `terms string length should be greater than 0 (got ${resp.terms.length})` ); }); diff --git a/x-pack/test/api_integration/apis/ml/results/get_category_examples.ts b/x-pack/test/api_integration/apis/ml/results/get_category_examples.ts index 10505c244deb8..271c26d35dce6 100644 --- a/x-pack/test/api_integration/apis/ml/results/get_category_examples.ts +++ b/x-pack/test/api_integration/apis/ml/results/get_category_examples.ts @@ -117,11 +117,9 @@ export default ({ getService }: FtrProviderContext) => { idSpace1 ); - expect(resp).to.eql( - expectedCategoryExamples1, - `response should be ${JSON.stringify(expectedCategoryExamples1)} (got ${JSON.stringify( - resp - )})` + expect(resp['1'].length).to.eql( + expectedCategoryExamples1['1'].length, + `response examples length should be ${expectedCategoryExamples1['1'].length} (got ${resp['1'].length})` ); }); @@ -135,11 +133,9 @@ export default ({ getService }: FtrProviderContext) => { idSpace1 ); - expect(resp).to.eql( - expectedCategoryExamples3, - `response should be ${JSON.stringify(expectedCategoryExamples3)} (got ${JSON.stringify( - resp - )})` + expect(resp['1'].length).to.eql( + expectedCategoryExamples3['1'].length, + `response examples length should be ${expectedCategoryExamples3['1'].length} (got ${resp['1'].length})` ); }); @@ -153,11 +149,11 @@ export default ({ getService }: FtrProviderContext) => { idSpace1 ); - expect(resp).to.not.eql( - expectedCategoryExamples3, - `response should not be ${JSON.stringify(expectedCategoryExamples3)} (got ${JSON.stringify( - resp - )})` + expect(Object.keys(resp)).to.not.eql( + Object.keys(expectedCategoryExamples3), + `response examples keys should be ${Object.keys( + expectedCategoryExamples3 + )} (got ${Object.keys(resp)})` ); }); @@ -182,11 +178,9 @@ export default ({ getService }: FtrProviderContext) => { idSpace1 ); - expect(resp).to.eql( - expectedCategoryExamples3, - `response should be ${JSON.stringify(expectedCategoryExamples3)} (got ${JSON.stringify( - resp - )})` + expect(resp['1'].length).to.eql( + expectedCategoryExamples3['1'].length, + `response examples length should be ${expectedCategoryExamples3['1'].length} (got ${resp['1'].length})` ); });