diff --git a/packages/consumption/test/customMatchers.ts b/packages/consumption/test/customMatchers.ts index dcca386f8..da38e13e5 100644 --- a/packages/consumption/test/customMatchers.ts +++ b/packages/consumption/test/customMatchers.ts @@ -1,5 +1,3 @@ -import { SerializableBase } from "@js-soft/ts-serval"; -import { set } from "lodash"; import { ErrorValidationResult, SuccessfulValidationResult, ValidationResult } from "../src"; expect.extend({ @@ -40,51 +38,6 @@ expect.extend({ } return { pass: true, message: () => "" }; - }, - - toStrictEqualExcluding(received: unknown, expected: unknown, ...excludes: string[]) { - if (received instanceof SerializableBase) { - received = received.toJSON(); - } - if (expected instanceof SerializableBase) { - expected = expected.toJSON(); - } - - const receivedClone = JSON.parse(JSON.stringify(received)); - const expectedClone = JSON.parse(JSON.stringify(expected)); - - excludes.forEach((exclud) => { - set(receivedClone, exclud, undefined); - set(expectedClone, exclud, undefined); - }); - - const matcherName = "toStrictEqual"; - const options = { - comment: "deep equality", - isNot: this.isNot, - promise: this.promise - }; - - const pass = this.equals(receivedClone, expectedClone, undefined, true); - - let message: string; - if (pass) { - message = - `${this.utils.matcherHint(matcherName, undefined, undefined, options)}\n\n` + - `Expected: not ${this.utils.printExpected(expectedClone)}\n${ - this.utils.stringify(expectedClone) === this.utils.stringify(receivedClone) ? "" : `Received: ${this.utils.printReceived(receivedClone)}` - }`; - } else { - message = `${this.utils.matcherHint(matcherName, undefined, undefined, options)}\n\n${this.utils.printDiffOrStringify( - expectedClone, - receivedClone, - "Expected", - "Received", - this.expand ?? true - )}`; - } - - return { message: () => message, pass }; } }); @@ -93,7 +46,6 @@ declare global { interface Matchers { successfulValidationResult(): R; errorValidationResult(error?: { code?: string; message?: string | RegExp }): R; - toStrictEqualExcluding(expected: unknown, ...ignoreProperties: string[]): R; } } } diff --git a/packages/consumption/test/modules/attributes/AttributeTagCollection.test.ts b/packages/consumption/test/modules/attributes/AttributeTagCollection.test.ts index 7369ac00c..61f833696 100644 --- a/packages/consumption/test/modules/attributes/AttributeTagCollection.test.ts +++ b/packages/consumption/test/modules/attributes/AttributeTagCollection.test.ts @@ -1,7 +1,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { AccountController, AttributeTagClient, ClientResult, Transport } from "@nmshd/transport"; import { spy, when } from "ts-mockito"; -import { ConsumptionController } from "../../../src"; +import { AttributeTagCollection, ConsumptionController } from "../../../src"; import { TestUtil } from "../../core/TestUtil"; describe("AttributeTagCollection", function () { @@ -72,6 +72,6 @@ describe("AttributeTagCollection", function () { when(mockedClient.getAttributeTagCollection()).thenResolve(ClientResult.ok(mockTags)); const tags = await consumptionController.attributes.getAttributeTagCollection(); - expect(tags.toJSON()).toStrictEqualExcluding(mockTags, "@type"); + expect(tags).toStrictEqual(AttributeTagCollection.from(mockTags)); }); });