From be35b6149d32f3fbf460cb23d1528b4ce4b598c4 Mon Sep 17 00:00:00 2001 From: Magnus Kuhn <127854942+Magnus-Kuhn@users.noreply.github.com> Date: Mon, 10 Feb 2025 11:47:13 +0100 Subject: [PATCH] Improve `test.each` test name individualisation (#412) * test: show correct test names in test.each * test: correct more usages --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- .../modules/requests/DecideRequestParametersValidator.test.ts | 2 +- .../CreateAttributeRequestItemProcessor.test.ts | 4 ++-- .../shareAttribute/ShareAttributeRequestItemProcessor.test.ts | 2 +- packages/content/test/attributeValues/ProprietaryJSON.test.ts | 2 +- .../test/attributes/RelationshipAttributeHints.test.ts | 2 +- .../attributes/ThirdPartyRelationshipAttributeQuery.test.ts | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/consumption/test/modules/requests/DecideRequestParametersValidator.test.ts b/packages/consumption/test/modules/requests/DecideRequestParametersValidator.test.ts index 2701dd5f1..e1fee13cd 100644 --- a/packages/consumption/test/modules/requests/DecideRequestParametersValidator.test.ts +++ b/packages/consumption/test/modules/requests/DecideRequestParametersValidator.test.ts @@ -278,7 +278,7 @@ describe("DecideRequestParametersValidator", function () { } ]; - test.each([...successParams, ...errorParams])("${value.description}", async function (data) { + test.each([...successParams, ...errorParams])("$description", async function (data) { const localRequest = LocalRequest.from({ id: CoreId.from(requestId), content: data.input.request, diff --git a/packages/consumption/test/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.test.ts b/packages/consumption/test/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.test.ts index 008f1cdf7..4d951ff67 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.test.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.test.ts @@ -419,7 +419,7 @@ describe("CreateAttributeRequestItemProcessor", function () { describe("applyIncomingResponseItem", function () { test.each([TestIdentity.PEER, TestIdentity.EMPTY])( - "in case of an IdentityAttribute with owner=${value.toString()}: creates a LocalAttribute with the Attribute from the RequestItem and the attributeId from the ResponseItem for the peer of the request ", + "in case of an IdentityAttribute with owner=%s: creates a LocalAttribute with the Attribute from the RequestItem and the attributeId from the ResponseItem for the peer of the request ", async function (attributeOwner: CoreAddress) { await Given.aRequestItemWithAnIdentityAttribute({ attributeOwner }); await Given.aCreateAttributeAcceptResponseItem(); @@ -430,7 +430,7 @@ describe("CreateAttributeRequestItemProcessor", function () { ); test.each([TestIdentity.PEER, TestIdentity.EMPTY, TestIdentity.CURRENT_IDENTITY])( - "in case of a RelationshipAttribute with owner=${value.toString()}: creates a LocalAttribute with the Attribute from the RequestItem and the attributeId from the ResponseItem for the peer of the request ", + "in case of a RelationshipAttribute with owner=%s: creates a LocalAttribute with the Attribute from the RequestItem and the attributeId from the ResponseItem for the peer of the request ", async function (attributeOwner: CoreAddress) { await Given.aRequestItemWithARelationshipAttribute({ attributeOwner }); await Given.aCreateAttributeAcceptResponseItem(); diff --git a/packages/consumption/test/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.test.ts b/packages/consumption/test/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.test.ts index 8b6472ec1..4b589460d 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.test.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.test.ts @@ -135,7 +135,7 @@ describe("ShareAttributeRequestItemProcessor", function () { message: "It doesn't make sense to share a RelationshipAttribute with its owner." } } - ])("returns ${value.result} when passing ${value.scenario}", async function (testParams) { + ])("returns $result when passing $scenario", async function (testParams) { const sender = testAccount.identity.address; const recipient = CoreAddress.from("Recipient"); diff --git a/packages/content/test/attributeValues/ProprietaryJSON.test.ts b/packages/content/test/attributeValues/ProprietaryJSON.test.ts index ca09dca02..c56d13685 100644 --- a/packages/content/test/attributeValues/ProprietaryJSON.test.ts +++ b/packages/content/test/attributeValues/ProprietaryJSON.test.ts @@ -24,7 +24,7 @@ describe("ProprietaryJSON", function () { } } ])( - "(de-)serialize %p", + "(de-)serialize %j", function (value: any) { const prop = ProprietaryJSON.from({ title: "a-title", value }); diff --git a/packages/content/test/attributes/RelationshipAttributeHints.test.ts b/packages/content/test/attributes/RelationshipAttributeHints.test.ts index c041adbf5..f41456f4e 100644 --- a/packages/content/test/attributes/RelationshipAttributeHints.test.ts +++ b/packages/content/test/attributes/RelationshipAttributeHints.test.ts @@ -24,7 +24,7 @@ describe("RelationshipAttributeHints", function () { expect(creationHints).toBeInstanceOf(RelationshipAttributeCreationHints); }); - test.each(["", "non-existing-value-type"])("should validate valueType ('${value}' should be invalid)", function (invalidValueType) { + test.each(["", "non-existing-value-type"])("should validate valueType ('%s' should be invalid)", function (invalidValueType) { expect(() => RelationshipAttributeCreationHints.from({ // @ts-expect-error diff --git a/packages/content/test/attributes/ThirdPartyRelationshipAttributeQuery.test.ts b/packages/content/test/attributes/ThirdPartyRelationshipAttributeQuery.test.ts index 51158322b..dde65c68d 100644 --- a/packages/content/test/attributes/ThirdPartyRelationshipAttributeQuery.test.ts +++ b/packages/content/test/attributes/ThirdPartyRelationshipAttributeQuery.test.ts @@ -34,7 +34,7 @@ describe("ThirdPartyRelationshipAttributeQuery", function () { { in: { address: "test" }, out: ["test"] }, { in: [{ address: "test" }], out: ["test"] }, { in: [{ address: "test" }, { address: "test" }], out: ["test", "test"] } - ])("accepts '$in' as thirdParty", function (params) { + ])("accepts %j as thirdParty", function (params) { const serialized = ThirdPartyRelationshipAttributeQuery.from({ key: "test", owner: "thirdParty", @@ -64,7 +64,7 @@ describe("ThirdPartyRelationshipAttributeQuery", function () { { in: "test", out: ["test"] }, { in: ["test"], out: ["test"] } ])( - "(de-)serialize ThirdPartyRelationshipAttributeQuery as a property with ${JSON.stringify(value)} as thirdParty", + "(de-)serialize ThirdPartyRelationshipAttributeQuery as a property with %j as thirdParty", function (params) { const test = TestTypeContainingThirdPartyRelationshipAttributeQueryTest.from({