diff --git a/sdk/documentintelligence/ai-document-intelligence-rest/test/public/node/analysis.spec.ts b/sdk/documentintelligence/ai-document-intelligence-rest/test/public/node/analysis.spec.ts index 0b6d5a665dbc..2a1e01226e05 100644 --- a/sdk/documentintelligence/ai-document-intelligence-rest/test/public/node/analysis.spec.ts +++ b/sdk/documentintelligence/ai-document-intelligence-rest/test/public/node/analysis.spec.ts @@ -78,12 +78,11 @@ describe("DocumentIntelligenceClient", () => { const pages = analyzeResult?.pages; const tables = analyzeResult?.tables; - assert.ok(pages && pages.length > 0, `Expected non-empty pages but got ${pages}`); assert.isNotEmpty(pages); assert.isNotEmpty(tables); const [table] = tables!; - assert.ok(table.boundingRegions?.[0]); + assert.isDefined(table.boundingRegions?.[0]); assert.equal(table.boundingRegions?.[0].pageNumber, 1); }); @@ -115,12 +114,9 @@ describe("DocumentIntelligenceClient", () => { const pages = analyzeResult?.pages; const paragraphs = analyzeResult?.paragraphs; - assert.ok( - paragraphs && paragraphs.length > 0, - `Expected non-empty paragraphs but got ${paragraphs}.`, - ); + assert.isNotEmpty(paragraphs); - assert.ok(pages && pages.length > 0, `Expect no-empty pages but got ${pages}`); + assert.isNotEmpty(pages); }); it("jpeg file stream", async () => { @@ -152,7 +148,7 @@ describe("DocumentIntelligenceClient", () => { assert.isNotEmpty(pages); assert.isNotEmpty(tables); const [table] = tables as DocumentTableOutput[]; - assert.ok(table.boundingRegions?.[0].polygon); + assert.isDefined(table.boundingRegions?.[0].polygon); assert.equal(table.boundingRegions?.[0].pageNumber, 1); }); @@ -184,7 +180,7 @@ describe("DocumentIntelligenceClient", () => { assert.isNotEmpty(pages); assert.isNotEmpty(tables); const [table] = tables as DocumentTableOutput[]; - assert.ok(table.boundingRegions?.[0].polygon); + assert.isDefined(table.boundingRegions?.[0].polygon); assert.equal(table.boundingRegions?.[0].pageNumber, 1); }); @@ -217,7 +213,7 @@ describe("DocumentIntelligenceClient", () => { assert.isNotEmpty(pages); assert.isNotEmpty(tables); const [table] = tables as DocumentTableOutput[]; - assert.ok(table.boundingRegions?.[0].polygon); + assert.isDefined(table.boundingRegions?.[0].polygon); assert.equal(table.boundingRegions?.[0].pageNumber, 1); }); @@ -248,7 +244,7 @@ describe("DocumentIntelligenceClient", () => { assert.isNotEmpty(tables); const [table] = tables as DocumentTableOutput[]; - assert.ok(table.boundingRegions?.[0].polygon); + assert.isDefined(table.boundingRegions?.[0].polygon); assert.equal(table.boundingRegions?.[0].pageNumber, 1); }); @@ -296,7 +292,7 @@ describe("DocumentIntelligenceClient", () => { await getLongRunningPoller(client, initialResponse, { ...testPollingOptions }); assert.fail("Expected an exception due to invalid locale."); } catch (ex: any) { - assert.ok((ex as Error).message.includes("Invalid argument.")); + assert.include((ex as Error).message, "Invalid argument."); } }); @@ -464,7 +460,7 @@ describe("DocumentIntelligenceClient", () => { throw response.body.error; } _model = response.body as DocumentModelDetailsOutput; - assert.ok(_model.modelId); + assert.isDefined(_model.modelId); } return _model; @@ -497,14 +493,14 @@ describe("DocumentIntelligenceClient", () => { const documents = analyzeResult?.documents; const pages = analyzeResult?.pages; - assert.ok(documents); + assert.isDefined(documents); assert.equal(documents?.[0].docType, `${modelName}:${modelName}`); - assert.ok(pages?.[0]); + assert.isDefined(pages?.[0]); /* There should be a table in the response, but it isn't recognized (maybe because it's too small or sparse) assert.isNotEmpty(tables); const [table] = tables!; - assert.ok(table.boundingRegions?.[0].boundingBox); + assert.isDefined(table.boundingRegions?.[0].boundingBox); assert.equal(table.boundingRegions?.[0].pageNumber, 1);*/ assert.equal(pages?.[0].pageNumber, 1); @@ -663,7 +659,7 @@ describe("DocumentIntelligenceClient", () => { assert.fail("Expected an exception due to invalid locale."); } catch (ex: any) { - assert.ok((ex as Error).message.includes("Invalid argument.")); + assert.include((ex as Error).message, "Invalid argument."); } }); }); @@ -699,7 +695,7 @@ describe("DocumentIntelligenceClient", () => { assert.isNotEmpty(pages); assert.isNotEmpty(tables); const [table] = tables!; - assert.ok(table.boundingRegions?.[0].polygon); + assert.isDefined(table.boundingRegions?.[0].polygon); assert.equal(table.boundingRegions?.[0].pageNumber, 1); }); @@ -731,7 +727,7 @@ describe("DocumentIntelligenceClient", () => { assert.isNotEmpty(pages); assert.isNotEmpty(tables); const [table] = tables!; - assert.ok(table.boundingRegions?.[0].polygon); + assert.isDefined(table.boundingRegions?.[0].polygon); assert.equal(table.boundingRegions?.[0].pageNumber, 1); }); @@ -755,7 +751,7 @@ describe("DocumentIntelligenceClient", () => { assert.fail("Expected an exception due to invalid locale."); } catch (ex: any) { - assert.ok((ex as Error).message.includes("Invalid argument.")); + assert.include((ex as Error).message, "Invalid argument."); } }); }); @@ -936,7 +932,7 @@ describe("DocumentIntelligenceClient", () => { if (isUnexpected(response)) { throw response.body.error; } - assert.ok(response.body); + assert.isDefined(response.body); assert.equal(response.body.resultId, batchResultId); assert.equal(response.body.status, "succeeded"); assert.equal(response.body.percentCompleted, 100); diff --git a/sdk/documentintelligence/ai-document-intelligence-rest/test/public/node/classifiers.spec.ts b/sdk/documentintelligence/ai-document-intelligence-rest/test/public/node/classifiers.spec.ts index 59fcc1acb2a5..15e39b4be902 100644 --- a/sdk/documentintelligence/ai-document-intelligence-rest/test/public/node/classifiers.spec.ts +++ b/sdk/documentintelligence/ai-document-intelligence-rest/test/public/node/classifiers.spec.ts @@ -62,11 +62,11 @@ describe("classifiers", () => { // Additionally check that the pages aren't empty and that there are some common fields set assert.isNotEmpty(analyzeResult?.pages); - assert.ok(analyzeResult?.pages![0].pageNumber); + assert.isDefined(analyzeResult?.pages![0].pageNumber); assert.isDefined(analyzeResult?.pages![0].angle); - assert.ok(analyzeResult?.pages![0].height); - assert.ok(analyzeResult?.pages![0].width); - assert.ok(analyzeResult?.pages![0].unit); + assert.isDefined(analyzeResult?.pages![0].height); + assert.isDefined(analyzeResult?.pages![0].width); + assert.isDefined(analyzeResult?.pages![0].unit); }); it("analyze from PNG file URL", async () => { @@ -107,7 +107,7 @@ describe("classifiers", () => { await client.path("/documentClassifiers/{classifierId}", classifierId).get(); assert.fail("Expected error while accessing a deleted classifier"); } catch (error: any) { - assert.ok(error); + assert.isDefined(error); } }); }); diff --git a/sdk/documentintelligence/ai-document-intelligence-rest/test/public/node/training.spec.ts b/sdk/documentintelligence/ai-document-intelligence-rest/test/public/node/training.spec.ts index 67e08ac0a211..c6851ccb7856 100644 --- a/sdk/documentintelligence/ai-document-intelligence-rest/test/public/node/training.spec.ts +++ b/sdk/documentintelligence/ai-document-intelligence-rest/test/public/node/training.spec.ts @@ -95,17 +95,14 @@ describe("model management", () => { it("validate model training response", async () => { const model = await requireModel(); - assert.ok(model, "Expecting valid response"); - assert.ok(model.modelId); + assert.isDefined(model); + assert.isDefined(model.modelId); assert.isNotEmpty(model.docTypes); const submodel = model.docTypes![model.modelId]; // When training with labels, we will have expectations for the names - assert.ok( - submodel.fieldSchema!["Signature"], - "Expecting field with name 'Signature' to be valid", - ); + assert.isDefined(submodel.fieldSchema!["Signature"]); }); /* @@ -145,15 +142,15 @@ describe("model management", () => { assert.isNotEmpty(tables); const [table] = tables!; - assert.ok(table.boundingRegions?.[0].polygon); + assert.isDefined(table.boundingRegions?.[0].polygon); assert.equal(table.boundingRegions?.[0].pageNumber, 1); - assert.ok(document?.fields); - assert.ok(document?.fields?.["Merchant"]); - assert.ok(document?.fields?.["DatedAs"]); - assert.ok(document?.fields?.["CompanyPhoneNumber"]); - assert.ok(document?.fields?.["CompanyName"]); - assert.ok(document?.fields?.["Signature"]); + assert.isDefined(document?.fields); + assert.isDefined(document?.fields?.["Merchant"]); + assert.isDefined(document?.fields?.["DatedAs"]); + assert.isDefined(document?.fields?.["CompanyPhoneNumber"]); + assert.isDefined(document?.fields?.["CompanyName"]); + assert.isDefined(document?.fields?.["Signature"]); }); }); @@ -168,7 +165,7 @@ describe("model management", () => { assert.strictEqual(modelDetails.body.modelId, model.modelId); assert.strictEqual(modelDetails.body.description, model.description); - assert.ok(modelDetails.body.docTypes); + assert.isDefined(modelDetails.body.docTypes); }); }); @@ -185,7 +182,7 @@ describe("model management", () => { const modelsInAccount: string[] = []; for await (const model of paginate(client, response)) { - assert.ok(model.modelId); + assert.isDefined(model.modelId); modelsInAccount.push(model.modelId); } @@ -273,9 +270,9 @@ describe("model management", () => { const response = await getLongRunningPoller(client, initialResponse); const composedModel = response.body as DocumentModelDetailsOutput; - assert.ok(composedModel.modelId); + assert.isDefined(composedModel.modelId); assert.equal(composedModel.modelId, modelId); - assert.ok(composedModel.docTypes); + assert.isDefined(composedModel.docTypes); // Submodels assert.equal(Object.entries(composedModel.docTypes ?? {}).length, 2); @@ -323,10 +320,10 @@ describe("model management", () => { const copyResponse = await getLongRunningPoller(client, copyInitResponse); const copyResult = copyResponse.body as DocumentModelDetailsOutput; - assert.ok(copyResult, "Expecting valid copy result"); + assert.isDefined(copyResult); assert.equal(copyResult.modelId, targetAuth.body.targetModelId); - assert.ok(copyResult.createdDateTime, "Expecting valid 'trainingStartedOn' property"); + assert.isDefined(copyResult.createdDateTime); const targetModel = await client.path("/documentModels/{modelId}", copyResult.modelId).get(); diff --git a/sdk/formrecognizer/ai-form-recognizer/test/public/browser/analysis.spec.ts b/sdk/formrecognizer/ai-form-recognizer/test/public/browser/analysis.spec.ts index 789464f871f3..84b2135305c1 100644 --- a/sdk/formrecognizer/ai-form-recognizer/test/public/browser/analysis.spec.ts +++ b/sdk/formrecognizer/ai-form-recognizer/test/public/browser/analysis.spec.ts @@ -32,10 +32,7 @@ describe("analysis (browser)", { timeout: 60000 }, () => { ); const { documents: receipts } = await poller.pollUntilDone(); - assert.ok( - receipts && receipts.length > 0, - `Expected at least one receipt, but got ${receipts}`, - ); + assert.isNotEmpty(receipts); const receipt = receipts![0]; assert.equal(receipt.docType, "receipt.retailMeal"); }); diff --git a/sdk/formrecognizer/ai-form-recognizer/test/public/node/analysis.spec.ts b/sdk/formrecognizer/ai-form-recognizer/test/public/node/analysis.spec.ts index a83dfc529615..38c3ce9c510d 100644 --- a/sdk/formrecognizer/ai-form-recognizer/test/public/node/analysis.spec.ts +++ b/sdk/formrecognizer/ai-form-recognizer/test/public/node/analysis.spec.ts @@ -32,7 +32,7 @@ import { describe, it, assert, beforeEach, afterEach } from "vitest"; import { getEndpoint, getSelectionMarkStorageContainerSasUrl } from "../../utils/injectables.js"; function assertDefined(value: unknown, message?: string): asserts value { - return assert.ok(value, message); + return assert.isDefined(value, message); } describe.each(authMethods)(`[%s] analysis (Node)`, (authMethod) => { @@ -67,12 +67,11 @@ describe.each(authMethods)(`[%s] analysis (Node)`, (authMethod) => { ); const { pages, tables } = await poller.pollUntilDone(); - assert.ok(pages && pages.length > 0, `Expected non-empty pages but got ${pages}`); assert.isNotEmpty(pages); assert.isNotEmpty(tables); const [table] = tables!; - assert.ok(table.boundingRegions?.[0]); + assert.isDefined(table.boundingRegions?.[0]); assert.equal(table.boundingRegions?.[0].pageNumber, 1); }); @@ -87,12 +86,9 @@ describe.each(authMethods)(`[%s] analysis (Node)`, (authMethod) => { ); const { pages, paragraphs } = await poller.pollUntilDone(); - assert.ok( - paragraphs && paragraphs.length > 0, - `Expected non-empty paragraphs but got ${paragraphs}.`, - ); + assert.isNotEmpty(paragraphs); - assert.ok(pages && pages.length > 0, `Expect no-empty pages but got ${pages}`); + assert.isNotEmpty(pages); }); it("jpeg file stream", async () => { @@ -110,7 +106,7 @@ describe.each(authMethods)(`[%s] analysis (Node)`, (authMethod) => { assert.isNotEmpty(tables); const [table] = tables as DocumentTable[]; - assert.ok(table.boundingRegions?.[0].polygon); + assert.isDefined(table.boundingRegions?.[0].polygon); assert.equal(table.boundingRegions?.[0].pageNumber, 1); }); @@ -129,7 +125,7 @@ describe.each(authMethods)(`[%s] analysis (Node)`, (authMethod) => { assert.isNotEmpty(tables); const [table] = tables as DocumentTable[]; - assert.ok(table.boundingRegions?.[0].polygon); + assert.isDefined(table.boundingRegions?.[0].polygon); assert.equal(table.boundingRegions?.[0].pageNumber, 1); }); @@ -148,7 +144,7 @@ describe.each(authMethods)(`[%s] analysis (Node)`, (authMethod) => { assert.isNotEmpty(tables); const [table] = tables as DocumentTable[]; - assert.ok(table.boundingRegions?.[0].polygon); + assert.isDefined(table.boundingRegions?.[0].polygon); assert.equal(table.boundingRegions?.[0].pageNumber, 1); }); @@ -166,7 +162,7 @@ describe.each(authMethods)(`[%s] analysis (Node)`, (authMethod) => { assert.isNotEmpty(tables); const [table] = tables as DocumentTable[]; - assert.ok(table.boundingRegions?.[0].polygon); + assert.isDefined(table.boundingRegions?.[0].polygon); assert.equal(table.boundingRegions?.[0].pageNumber, 1); }); @@ -187,7 +183,7 @@ describe.each(authMethods)(`[%s] analysis (Node)`, (authMethod) => { /* There should be a table on the page, but the layout engine does not recognize it, maybe because it is too small and sparse. assert.isNotEmpty(tables); const [table] = tables; - assert.ok(table.boundingRegions?.[0].boundingBox); + assert.isDefined(table.boundingRegions?.[0].boundingBox); assert.equal(table.boundingRegions?.[0].pageNumber, 1);*/ assert.equal(pages?.[0].pageNumber, 1); @@ -370,7 +366,7 @@ describe.each(authMethods)(`[%s] analysis (Node)`, (authMethod) => { ); _model = await poller.pollUntilDone(); - assert.ok(_model.modelId); + assert.isDefined(_model.modelId); } return _model; @@ -386,19 +382,19 @@ describe.each(authMethods)(`[%s] analysis (Node)`, (authMethod) => { const poller = await client.beginAnalyzeDocument(modelId, stream, testPollingOptions); const { pages, documents } = await poller.pollUntilDone(); - assert.ok(documents); + assert.isDefined(documents); assert.equal(documents?.[0].docType, `${modelName}:${modelName}`); const amexMark = documents?.[0].fields["AMEX_SELECTION_MARK"] as DocumentSelectionMarkField; assert.equal(amexMark.kind, "selectionMark"); assert.equal(amexMark.value, "selected"); - assert.ok(pages?.[0]); + assert.isDefined(pages?.[0]); /* There should be a table in the response, but it isn't recognized (maybe because it's too small or sparse) assert.isNotEmpty(tables); const [table] = tables!; - assert.ok(table.boundingRegions?.[0].boundingBox); + assert.isDefined(table.boundingRegions?.[0].boundingBox); assert.equal(table.boundingRegions?.[0].pageNumber, 1);*/ assert.equal(pages?.[0].pageNumber, 1); @@ -833,7 +829,7 @@ describe.each(authMethods)(`[%s] analysis (Node)`, (authMethod) => { assert.isNotEmpty(pages); assert.isNotEmpty(tables); const [table] = tables!; - assert.ok(table.boundingRegions?.[0].polygon); + assert.isDefined(table.boundingRegions?.[0].polygon); assert.equal(table.boundingRegions?.[0].pageNumber, 1); validator(invoice as AnalyzedDocument); @@ -854,7 +850,7 @@ describe.each(authMethods)(`[%s] analysis (Node)`, (authMethod) => { assert.isNotEmpty(pages); assert.isNotEmpty(tables); const [table] = tables!; - assert.ok(table.boundingRegions?.[0].polygon); + assert.isDefined(table.boundingRegions?.[0].polygon); assert.equal(table.boundingRegions?.[0].pageNumber, 1); validator(invoice as AnalyzedDocument); diff --git a/sdk/formrecognizer/ai-form-recognizer/test/public/node/classifiers.spec.ts b/sdk/formrecognizer/ai-form-recognizer/test/public/node/classifiers.spec.ts index 0b6dad1761a8..1ee1c439aa45 100644 --- a/sdk/formrecognizer/ai-form-recognizer/test/public/node/classifiers.spec.ts +++ b/sdk/formrecognizer/ai-form-recognizer/test/public/node/classifiers.spec.ts @@ -85,7 +85,7 @@ describe.each(authMethods)(`[%s] document classifiers`, (authMethod) => { _classifier = await poller.pollUntilDone(); - assert.ok(_classifier.classifierId); + assert.isDefined(_classifier.classifierId); } return _classifier; @@ -114,11 +114,11 @@ describe.each(authMethods)(`[%s] document classifiers`, (authMethod) => { // Additionally check that the pages aren't empty and that there are some common fields set assert.isNotEmpty(result.pages); - assert.ok(result.pages![0].pageNumber); + assert.isDefined(result.pages![0].pageNumber); assert.isDefined(result.pages![0].angle); - assert.ok(result.pages![0].height); - assert.ok(result.pages![0].width); - assert.ok(result.pages![0].unit); + assert.isDefined(result.pages![0].height); + assert.isDefined(result.pages![0].width); + assert.isDefined(result.pages![0].unit); }); it("analyze from PNG file URL", async () => { diff --git a/sdk/formrecognizer/ai-form-recognizer/test/public/training.spec.ts b/sdk/formrecognizer/ai-form-recognizer/test/public/training.spec.ts index e2fae5ffbac3..7e5123c01197 100644 --- a/sdk/formrecognizer/ai-form-recognizer/test/public/training.spec.ts +++ b/sdk/formrecognizer/ai-form-recognizer/test/public/training.spec.ts @@ -103,17 +103,14 @@ describe.each(authMethods)(`[%s] model management`, (authMethod) => { it("validate model training response", async () => { const model = await requireModel(); - assert.ok(model, "Expecting valid response"); - assert.ok(model.modelId); + assert.isDefined(model); + assert.isDefined(model.modelId); assert.isNotEmpty(model.docTypes); const submodel = model.docTypes![model.modelId]; // When training with labels, we will have expectations for the names - assert.ok( - submodel.fieldSchema["Signature"], - "Expecting field with name 'Signature' to be valid", - ); + assert.isDefined(submodel.fieldSchema["Signature"]); }); /* @@ -152,15 +149,15 @@ describe.each(authMethods)(`[%s] model management`, (authMethod) => { assert.isNotEmpty(tables); const [table] = tables!; - assert.ok(table.boundingRegions?.[0].polygon); + assert.isDefined(table.boundingRegions?.[0].polygon); assert.equal(table.boundingRegions?.[0].pageNumber, 1); - assert.ok(document?.fields); - assert.ok(document?.fields["Merchant"]); - assert.ok(document?.fields["DatedAs"]); - assert.ok(document?.fields["CompanyPhoneNumber"]); - assert.ok(document?.fields["CompanyName"]); - assert.ok(document?.fields["Signature"]); + assert.isDefined(document?.fields); + assert.isDefined(document?.fields["Merchant"]); + assert.isDefined(document?.fields["DatedAs"]); + assert.isDefined(document?.fields["CompanyPhoneNumber"]); + assert.isDefined(document?.fields["CompanyName"]); + assert.isDefined(document?.fields["Signature"]); }); }); @@ -171,7 +168,7 @@ describe.each(authMethods)(`[%s] model management`, (authMethod) => { assert.strictEqual(modelDetails.modelId, model.modelId); assert.strictEqual(modelDetails.description, model.description); - assert.ok(modelDetails.docTypes); + assert.isDefined(modelDetails.docTypes); }); }); @@ -198,7 +195,7 @@ describe.each(authMethods)(`[%s] model management`, (authMethod) => { it("iterate models in account", async () => { const modelsInAccount = []; for await (const model of client.listDocumentModels()) { - assert.ok(model.modelId); + assert.isDefined(model.modelId); modelsInAccount.push(model.modelId); } @@ -210,8 +207,8 @@ describe.each(authMethods)(`[%s] model management`, (authMethod) => { it("old-style iteration with next model info", async () => { const iter = client.listDocumentModels(); const item = getYieldedValue(await iter.next()); - assert.ok(item, `Expecting a model but got ${item}`); - assert.ok(item.modelId, `Expecting a model id but got ${item.modelId}`); + assert.isDefined(item); + assert.isDefined(item.modelId); }); it("delete models from the account", async () => { @@ -256,7 +253,7 @@ describe.each(authMethods)(`[%s] model management`, (authMethod) => { assert.equal(model.modelId, modelId); assert.equal(model.modelId, modelId); - assert.ok(model.docTypes); + assert.isDefined(model.docTypes); return model.modelId; } @@ -271,9 +268,9 @@ describe.each(authMethods)(`[%s] model management`, (authMethod) => { ); const composedModel = await composePoller.pollUntilDone(); - assert.ok(composedModel.modelId); + assert.isDefined(composedModel.modelId); assert.equal(composedModel.modelId, modelId); - assert.ok(composedModel.docTypes); + assert.isDefined(composedModel.docTypes); // Submodels assert.equal(Object.entries(composedModel.docTypes ?? {}).length, 2); @@ -320,10 +317,10 @@ describe.each(authMethods)(`[%s] model management`, (authMethod) => { ); const copyResult = await poller.pollUntilDone(); - assert.ok(copyResult, "Expecting valid copy result"); + assert.isDefined(copyResult); assert.equal(copyResult.modelId, targetAuth.targetModelId); - assert.ok(copyResult.createdOn, "Expecting valid 'trainingStartedOn' property"); + assert.isDefined(copyResult.createdOn); const targetModel = await trainingClient.getDocumentModel(copyResult.modelId);