diff --git a/packages/entity/src/AuthorizationResultBasedEntityAssociationLoader.ts b/packages/entity/src/AuthorizationResultBasedEntityAssociationLoader.ts index 542b13c5..1cc864ca 100644 --- a/packages/entity/src/AuthorizationResultBasedEntityAssociationLoader.ts +++ b/packages/entity/src/AuthorizationResultBasedEntityAssociationLoader.ts @@ -18,14 +18,16 @@ export default class AuthorizationResultBasedEntityAssociationLoader< TEntity extends ReadonlyEntity, TSelectedFields extends keyof TFields, > { - constructor(private readonly entity: TEntity) {} + constructor( + private readonly entity: TEntity, + private readonly queryContext: EntityQueryContext, + ) {} /** * Load an associated entity identified by a field value of this entity. In a relational database, * the field in this entity is a foreign key to the ID of the associated entity. * @param fieldIdentifyingAssociatedEntity - field of this entity containing the ID of the associated entity * @param associatedEntityClass - class of the associated entity - * @param queryContext - query context in which to perform the load */ async loadAssociatedEntityAsync< TIdentifyingField extends keyof Pick, @@ -55,11 +57,6 @@ export default class AuthorizationResultBasedEntityAssociationLoader< TAssociatedPrivacyPolicy, TAssociatedSelectedFields >, - queryContext: EntityQueryContext = this.entity - .getViewerContext() - .getViewerScopedEntityCompanionForClass(associatedEntityClass) - .getQueryContextProvider() - .getQueryContext(), ): Promise< Result > { @@ -74,7 +71,7 @@ export default class AuthorizationResultBasedEntityAssociationLoader< .getViewerContext() .getViewerScopedEntityCompanionForClass(associatedEntityClass) .getLoaderFactory() - .forLoad(queryContext, { previousValue: null, cascadingDeleteCause: null }); + .forLoad(this.queryContext, { previousValue: null, cascadingDeleteCause: null }); return (await loader.loadByIDAsync(associatedEntityID as unknown as TAssociatedID)) as Result< null extends TFields[TIdentifyingField] ? TAssociatedEntity | null : TAssociatedEntity @@ -88,7 +85,6 @@ export default class AuthorizationResultBasedEntityAssociationLoader< * where this entity has many associated entities. * @param associatedEntityClass - class of the associated entities * @param associatedEntityFieldContainingThisID - field of associated entity which contains the ID of this entity - * @param queryContext - query context in which to perform the load */ async loadManyAssociatedEntitiesAsync< TAssociatedFields extends object, @@ -117,18 +113,13 @@ export default class AuthorizationResultBasedEntityAssociationLoader< TAssociatedSelectedFields >, associatedEntityFieldContainingThisID: keyof Pick, - queryContext: EntityQueryContext = this.entity - .getViewerContext() - .getViewerScopedEntityCompanionForClass(associatedEntityClass) - .getQueryContextProvider() - .getQueryContext(), ): Promise[]> { const thisID = this.entity.getID(); const loader = this.entity .getViewerContext() .getViewerScopedEntityCompanionForClass(associatedEntityClass) .getLoaderFactory() - .forLoad(queryContext, { previousValue: null, cascadingDeleteCause: null }); + .forLoad(this.queryContext, { previousValue: null, cascadingDeleteCause: null }); return await loader.loadManyByFieldEqualingAsync( associatedEntityFieldContainingThisID, thisID as any, @@ -141,7 +132,6 @@ export default class AuthorizationResultBasedEntityAssociationLoader< * @param fieldIdentifyingAssociatedEntity - field of this entity containing the value with which to look up associated entity * @param associatedEntityClass - class of the associated entity * @param associatedEntityLookupByField - field of associated entity with which to look up the associated entity - * @param queryContext - query context in which to perform the load */ async loadAssociatedEntityByFieldEqualingAsync< TAssociatedFields extends object, @@ -171,11 +161,6 @@ export default class AuthorizationResultBasedEntityAssociationLoader< TAssociatedSelectedFields >, associatedEntityLookupByField: keyof Pick, - queryContext: EntityQueryContext = this.entity - .getViewerContext() - .getViewerScopedEntityCompanionForClass(associatedEntityClass) - .getQueryContextProvider() - .getQueryContext(), ): Promise | null> { const associatedFieldValue = this.entity.getField(fieldIdentifyingAssociatedEntity); if (!associatedFieldValue) { @@ -185,7 +170,7 @@ export default class AuthorizationResultBasedEntityAssociationLoader< .getViewerContext() .getViewerScopedEntityCompanionForClass(associatedEntityClass) .getLoaderFactory() - .forLoad(queryContext, { previousValue: null, cascadingDeleteCause: null }); + .forLoad(this.queryContext, { previousValue: null, cascadingDeleteCause: null }); return await loader.loadByFieldEqualingAsync( associatedEntityLookupByField, associatedFieldValue as any, @@ -198,7 +183,6 @@ export default class AuthorizationResultBasedEntityAssociationLoader< * @param fieldIdentifyingAssociatedEntity - field of this entity containing the value with which to look up associated entities * @param associatedEntityClass - class of the associated entities * @param associatedEntityLookupByField - field of associated entities with which to look up the associated entities - * @param queryContext - query context in which to perform the load */ async loadManyAssociatedEntitiesByFieldEqualingAsync< TAssociatedFields extends object, @@ -228,11 +212,6 @@ export default class AuthorizationResultBasedEntityAssociationLoader< TAssociatedSelectedFields >, associatedEntityLookupByField: keyof Pick, - queryContext: EntityQueryContext = this.entity - .getViewerContext() - .getViewerScopedEntityCompanionForClass(associatedEntityClass) - .getQueryContextProvider() - .getQueryContext(), ): Promise[]> { const associatedFieldValue = this.entity.getField(fieldIdentifyingAssociatedEntity); if (!associatedFieldValue) { @@ -243,7 +222,7 @@ export default class AuthorizationResultBasedEntityAssociationLoader< .getViewerContext() .getViewerScopedEntityCompanionForClass(associatedEntityClass) .getLoaderFactory() - .forLoad(queryContext, { previousValue: null, cascadingDeleteCause: null }); + .forLoad(this.queryContext, { previousValue: null, cascadingDeleteCause: null }); return await loader.loadManyByFieldEqualingAsync( associatedEntityLookupByField, associatedFieldValue as any, @@ -253,8 +232,7 @@ export default class AuthorizationResultBasedEntityAssociationLoader< /** * Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each * fold step, load an associated entity identified by a field value of the current fold value. - * @param loadDirectives - associated entity load directives instructing each step of the fold - * @param queryContext - query context in which to perform the loads + * @param loadDirectives - associated entity load directives instructing each step of the folds */ async loadAssociatedEntityThroughAsync< TFields2 extends object, @@ -281,14 +259,12 @@ export default class AuthorizationResultBasedEntityAssociationLoader< TSelectedFields2 >, ], - queryContext?: EntityQueryContext, ): Promise | null>; /** * Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each * fold step, load an associated entity identified by a field value of the current fold value. - * @param loadDirectives - associated entity load directives instructing each step of the fold - * @param queryContext - query context in which to perform the loads + * @param loadDirectives - associated entity load directives instructing each step of the folds */ async loadAssociatedEntityThroughAsync< TFields2 extends object, @@ -336,14 +312,12 @@ export default class AuthorizationResultBasedEntityAssociationLoader< TSelectedFields3 >, ], - queryContext?: EntityQueryContext, ): Promise | null>; /** * Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each * fold step, load an associated entity identified by a field value of the current fold value. - * @param loadDirectives - associated entity load directives instructing each step of the fold - * @param queryContext - query context in which to perform the loads + * @param loadDirectives - associated entity load directives instructing each step of the folds */ async loadAssociatedEntityThroughAsync< TFields2 extends object, @@ -412,23 +386,19 @@ export default class AuthorizationResultBasedEntityAssociationLoader< TSelectedFields4 >, ], - queryContext?: EntityQueryContext, ): Promise | null>; /** * Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each * fold step, load an associated entity identified by a field value of the current fold value. - * @param loadDirectives - associated entity load directives instructing each step of the fold - * @param queryContext - query context in which to perform the loads + * @param loadDirectives - associated entity load directives instructing each step of the folds */ async loadAssociatedEntityThroughAsync( loadDirectives: EntityLoadThroughDirective[], - queryContext?: EntityQueryContext, ): Promise> | null>; async loadAssociatedEntityThroughAsync( loadDirectives: EntityLoadThroughDirective[], - queryContext?: EntityQueryContext, ): Promise> | null> { let currentEntity: ReadonlyEntity = this.entity; for (const loadDirective of loadDirectives) { @@ -440,23 +410,18 @@ export default class AuthorizationResultBasedEntityAssociationLoader< let associatedEntityResult: Result> | null; if (associatedEntityLookupByField) { associatedEntityResult = await currentEntity - .associationLoader() + .associationLoader(this.queryContext) .withAuthorizationResults() .loadAssociatedEntityByFieldEqualingAsync( fieldIdentifyingAssociatedEntity, associatedEntityClass, associatedEntityLookupByField, - queryContext, ); } else { const associatedEntityResultLocal = await currentEntity - .associationLoader() + .associationLoader(this.queryContext) .withAuthorizationResults() - .loadAssociatedEntityAsync( - fieldIdentifyingAssociatedEntity, - associatedEntityClass, - queryContext, - ); + .loadAssociatedEntityAsync(fieldIdentifyingAssociatedEntity, associatedEntityClass); if (associatedEntityResultLocal.ok && associatedEntityResultLocal.value === null) { associatedEntityResult = null; diff --git a/packages/entity/src/EnforcingEntityAssociationLoader.ts b/packages/entity/src/EnforcingEntityAssociationLoader.ts index ae1a6567..d812ffbf 100644 --- a/packages/entity/src/EnforcingEntityAssociationLoader.ts +++ b/packages/entity/src/EnforcingEntityAssociationLoader.ts @@ -5,7 +5,6 @@ import AuthorizationResultBasedEntityAssociationLoader, { } from './AuthorizationResultBasedEntityAssociationLoader'; import { IEntityClass } from './Entity'; import EntityPrivacyPolicy from './EntityPrivacyPolicy'; -import { EntityQueryContext } from './EntityQueryContext'; import ReadonlyEntity from './ReadonlyEntity'; import ViewerContext from './ViewerContext'; import { enforceResultsAsync } from './entityUtils'; @@ -37,7 +36,6 @@ export default class EnforcingEntityAssociationLoader< * the field in this entity is a foreign key to the ID of the associated entity. * @param fieldIdentifyingAssociatedEntity - field of this entity containing the ID of the associated entity * @param associatedEntityClass - class of the associated entity - * @param queryContext - query context in which to perform the load */ async loadAssociatedEntityAsync< TIdentifyingField extends keyof Pick, @@ -67,7 +65,6 @@ export default class EnforcingEntityAssociationLoader< TAssociatedPrivacyPolicy, TAssociatedSelectedFields >, - queryContext?: EntityQueryContext, ): Promise< null extends TFields[TIdentifyingField] ? TAssociatedEntity | null : TAssociatedEntity > { @@ -75,7 +72,6 @@ export default class EnforcingEntityAssociationLoader< this.authorizationResultBasedEntityAssociationLoader.loadAssociatedEntityAsync( fieldIdentifyingAssociatedEntity, associatedEntityClass, - queryContext, ), ); } @@ -87,7 +83,6 @@ export default class EnforcingEntityAssociationLoader< * where this entity has many associated entities. * @param associatedEntityClass - class of the associated entities * @param associatedEntityFieldContainingThisID - field of associated entity which contains the ID of this entity - * @param queryContext - query context in which to perform the load */ async loadManyAssociatedEntitiesAsync< TAssociatedFields extends object, @@ -116,13 +111,11 @@ export default class EnforcingEntityAssociationLoader< TAssociatedSelectedFields >, associatedEntityFieldContainingThisID: keyof Pick, - queryContext?: EntityQueryContext, ): Promise { return await enforceResultsAsync( this.authorizationResultBasedEntityAssociationLoader.loadManyAssociatedEntitiesAsync( associatedEntityClass, associatedEntityFieldContainingThisID, - queryContext, ), ); } @@ -133,7 +126,6 @@ export default class EnforcingEntityAssociationLoader< * @param fieldIdentifyingAssociatedEntity - field of this entity containing the value with which to look up associated entity * @param associatedEntityClass - class of the associated entity * @param associatedEntityLookupByField - field of associated entity with which to look up the associated entity - * @param queryContext - query context in which to perform the load */ async loadAssociatedEntityByFieldEqualingAsync< TAssociatedFields extends object, @@ -163,14 +155,12 @@ export default class EnforcingEntityAssociationLoader< TAssociatedSelectedFields >, associatedEntityLookupByField: keyof Pick, - queryContext?: EntityQueryContext, ): Promise { const result = await this.authorizationResultBasedEntityAssociationLoader.loadAssociatedEntityByFieldEqualingAsync( fieldIdentifyingAssociatedEntity, associatedEntityClass, associatedEntityLookupByField, - queryContext, ); return result?.enforceValue() ?? null; } @@ -181,7 +171,6 @@ export default class EnforcingEntityAssociationLoader< * @param fieldIdentifyingAssociatedEntity - field of this entity containing the value with which to look up associated entities * @param associatedEntityClass - class of the associated entities * @param associatedEntityLookupByField - field of associated entities with which to look up the associated entities - * @param queryContext - query context in which to perform the load */ async loadManyAssociatedEntitiesByFieldEqualingAsync< TAssociatedFields extends object, @@ -211,14 +200,12 @@ export default class EnforcingEntityAssociationLoader< TAssociatedSelectedFields >, associatedEntityLookupByField: keyof Pick, - queryContext?: EntityQueryContext, ): Promise { return await enforceResultsAsync( this.authorizationResultBasedEntityAssociationLoader.loadManyAssociatedEntitiesByFieldEqualingAsync( fieldIdentifyingAssociatedEntity, associatedEntityClass, associatedEntityLookupByField, - queryContext, ), ); } @@ -226,8 +213,7 @@ export default class EnforcingEntityAssociationLoader< /** * Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each * fold step, load an associated entity identified by a field value of the current fold value. - * @param loadDirectives - associated entity load directives instructing each step of the fold - * @param queryContext - query context in which to perform the loads + * @param loadDirectives - associated entity load directives instructing each step of the folds */ async loadAssociatedEntityThroughAsync< TFields2 extends object, @@ -254,14 +240,12 @@ export default class EnforcingEntityAssociationLoader< TSelectedFields2 >, ], - queryContext?: EntityQueryContext, ): Promise; /** * Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each * fold step, load an associated entity identified by a field value of the current fold value. - * @param loadDirectives - associated entity load directives instructing each step of the fold - * @param queryContext - query context in which to perform the loads + * @param loadDirectives - associated entity load directives instructing each step of the folds */ async loadAssociatedEntityThroughAsync< TFields2 extends object, @@ -309,14 +293,12 @@ export default class EnforcingEntityAssociationLoader< TSelectedFields3 >, ], - queryContext?: EntityQueryContext, ): Promise; /** * Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each * fold step, load an associated entity identified by a field value of the current fold value. - * @param loadDirectives - associated entity load directives instructing each step of the fold - * @param queryContext - query context in which to perform the loads + * @param loadDirectives - associated entity load directives instructing each step of the folds */ async loadAssociatedEntityThroughAsync< TFields2 extends object, @@ -385,28 +367,23 @@ export default class EnforcingEntityAssociationLoader< TSelectedFields4 >, ], - queryContext?: EntityQueryContext, ): Promise; /** * Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each * fold step, load an associated entity identified by a field value of the current fold value. - * @param loadDirectives - associated entity load directives instructing each step of the fold - * @param queryContext - query context in which to perform the loads + * @param loadDirectives - associated entity load directives instructing each step of the folds */ async loadAssociatedEntityThroughAsync( loadDirectives: EntityLoadThroughDirective[], - queryContext?: EntityQueryContext, ): Promise | null>; async loadAssociatedEntityThroughAsync( loadDirectives: EntityLoadThroughDirective[], - queryContext?: EntityQueryContext, ): Promise | null> { const result = await this.authorizationResultBasedEntityAssociationLoader.loadAssociatedEntityThroughAsync( loadDirectives, - queryContext, ); return result?.enforceValue() ?? null; } diff --git a/packages/entity/src/EntityAssociationLoader.ts b/packages/entity/src/EntityAssociationLoader.ts index 8f7c3106..7f89dc14 100644 --- a/packages/entity/src/EntityAssociationLoader.ts +++ b/packages/entity/src/EntityAssociationLoader.ts @@ -1,5 +1,7 @@ import AuthorizationResultBasedEntityAssociationLoader from './AuthorizationResultBasedEntityAssociationLoader'; import EnforcingEntityAssociationLoader from './EnforcingEntityAssociationLoader'; +import { IEntityClass } from './Entity'; +import { EntityQueryContext } from './EntityQueryContext'; import ReadonlyEntity from './ReadonlyEntity'; import ViewerContext from './ViewerContext'; @@ -15,7 +17,23 @@ export default class EntityAssociationLoader< TEntity extends ReadonlyEntity, TSelectedFields extends keyof TFields, > { - constructor(private readonly entity: TEntity) {} + constructor( + private readonly entity: TEntity, + private readonly queryContext: EntityQueryContext = entity + .getViewerContext() + .getViewerScopedEntityCompanionForClass( + entity.constructor as IEntityClass< + TFields, + TID, + TViewerContext, + TEntity, + any, + TSelectedFields + >, + ) + .getQueryContextProvider() + .getQueryContext(), + ) {} /** * Enforcing entity association loader. All loads through this loader are @@ -44,6 +62,6 @@ export default class EntityAssociationLoader< TEntity, TSelectedFields > { - return new AuthorizationResultBasedEntityAssociationLoader(this.entity); + return new AuthorizationResultBasedEntityAssociationLoader(this.entity, this.queryContext); } } diff --git a/packages/entity/src/ReadonlyEntity.ts b/packages/entity/src/ReadonlyEntity.ts index d23fb9d1..3aee3dcc 100644 --- a/packages/entity/src/ReadonlyEntity.ts +++ b/packages/entity/src/ReadonlyEntity.ts @@ -84,14 +84,10 @@ export default abstract class ReadonlyEntity< /** * @returns EntityAssociationLoader for this entity */ - associationLoader(): EntityAssociationLoader< - TFields, - TID, - TViewerContext, - this, - TSelectedFields - > { - return new EntityAssociationLoader(this); + associationLoader( + queryContext?: EntityQueryContext, + ): EntityAssociationLoader { + return new EntityAssociationLoader(this, queryContext); } /** diff --git a/packages/entity/src/__tests__/EnforcingEntityAssociationLoader-test.ts b/packages/entity/src/__tests__/EnforcingEntityAssociationLoader-test.ts index ddafa2b0..2fb267bd 100644 --- a/packages/entity/src/__tests__/EnforcingEntityAssociationLoader-test.ts +++ b/packages/entity/src/__tests__/EnforcingEntityAssociationLoader-test.ts @@ -11,22 +11,14 @@ describe(EnforcingEntityAssociationLoader, () => { mock>(); const rejection = new Error(); when( - nonEnforcingEntityAssociationLoaderMock.loadAssociatedEntityAsync( - anything(), - anything(), - anything(), - ), + nonEnforcingEntityAssociationLoaderMock.loadAssociatedEntityAsync(anything(), anything()), ).thenResolve(result(rejection)); const nonEnforcingEntityAssociationLoader = instance(nonEnforcingEntityAssociationLoaderMock); const enforcingEntityAssociationLoader = new EnforcingEntityAssociationLoader( nonEnforcingEntityAssociationLoader, ); await expect( - enforcingEntityAssociationLoader.loadAssociatedEntityAsync( - anything(), - anything(), - anything(), - ), + enforcingEntityAssociationLoader.loadAssociatedEntityAsync(anything(), anything()), ).rejects.toThrow(rejection); }); @@ -35,18 +27,14 @@ describe(EnforcingEntityAssociationLoader, () => { mock>(); const resolved = {} as any; when( - nonEnforcingEntityAssociationLoaderMock.loadAssociatedEntityAsync( - anything(), - anything(), - anything(), - ), + nonEnforcingEntityAssociationLoaderMock.loadAssociatedEntityAsync(anything(), anything()), ).thenResolve(result(resolved)); const nonEnforcingEntityAssociationLoader = instance(nonEnforcingEntityAssociationLoaderMock); const enforcingEntityLoader = new EnforcingEntityAssociationLoader( nonEnforcingEntityAssociationLoader, ); await expect( - enforcingEntityLoader.loadAssociatedEntityAsync(anything(), anything(), anything()), + enforcingEntityLoader.loadAssociatedEntityAsync(anything(), anything()), ).resolves.toEqual(resolved); }); }); @@ -60,7 +48,6 @@ describe(EnforcingEntityAssociationLoader, () => { nonEnforcingEntityAssociationLoaderMock.loadManyAssociatedEntitiesAsync( anything(), anything() as never, - anything(), ), ).thenResolve([result(rejection)]); const nonEnforcingEntityAssociationLoader = instance(nonEnforcingEntityAssociationLoaderMock); @@ -71,7 +58,6 @@ describe(EnforcingEntityAssociationLoader, () => { enforcingEntityAssociationLoader.loadManyAssociatedEntitiesAsync( anything(), anything() as never, - anything(), ), ).rejects.toThrow(rejection); }); @@ -84,7 +70,6 @@ describe(EnforcingEntityAssociationLoader, () => { nonEnforcingEntityAssociationLoaderMock.loadManyAssociatedEntitiesAsync( anything(), anything() as never, - anything(), ), ).thenResolve([result(resolved)]); const nonEnforcingEntityAssociationLoader = instance(nonEnforcingEntityAssociationLoaderMock); @@ -92,11 +77,7 @@ describe(EnforcingEntityAssociationLoader, () => { nonEnforcingEntityAssociationLoader, ); await expect( - enforcingEntityLoader.loadManyAssociatedEntitiesAsync( - anything(), - anything() as never, - anything(), - ), + enforcingEntityLoader.loadManyAssociatedEntitiesAsync(anything(), anything() as never), ).resolves.toEqual([resolved]); }); }); @@ -111,7 +92,6 @@ describe(EnforcingEntityAssociationLoader, () => { anything(), anything(), anything() as never, - anything(), ), ).thenResolve(result(rejection)); const nonEnforcingEntityAssociationLoader = instance(nonEnforcingEntityAssociationLoaderMock); @@ -123,7 +103,6 @@ describe(EnforcingEntityAssociationLoader, () => { anything(), anything(), anything() as never, - anything(), ), ).rejects.toThrow(rejection); }); @@ -137,7 +116,6 @@ describe(EnforcingEntityAssociationLoader, () => { anything(), anything(), anything() as never, - anything(), ), ).thenResolve(result(resolved)); const nonEnforcingEntityAssociationLoader = instance(nonEnforcingEntityAssociationLoaderMock); @@ -149,7 +127,6 @@ describe(EnforcingEntityAssociationLoader, () => { anything(), anything(), anything() as never, - anything(), ), ).resolves.toEqual(resolved); }); @@ -163,7 +140,6 @@ describe(EnforcingEntityAssociationLoader, () => { anything(), anything(), anything() as never, - anything(), ), ).thenResolve(resolved); const nonEnforcingEntityAssociationLoader = instance(nonEnforcingEntityAssociationLoaderMock); @@ -175,7 +151,6 @@ describe(EnforcingEntityAssociationLoader, () => { anything(), anything(), anything() as never, - anything(), ), ).resolves.toEqual(resolved); }); @@ -191,7 +166,6 @@ describe(EnforcingEntityAssociationLoader, () => { anything(), anything(), anything() as never, - anything(), ), ).thenResolve([result(rejection)]); const nonEnforcingEntityAssociationLoader = instance(nonEnforcingEntityAssociationLoaderMock); @@ -203,7 +177,6 @@ describe(EnforcingEntityAssociationLoader, () => { anything(), anything(), anything() as never, - anything(), ), ).rejects.toThrow(rejection); }); @@ -217,7 +190,6 @@ describe(EnforcingEntityAssociationLoader, () => { anything(), anything(), anything() as never, - anything(), ), ).thenResolve([result(resolved)]); const nonEnforcingEntityAssociationLoader = instance(nonEnforcingEntityAssociationLoaderMock); @@ -229,7 +201,6 @@ describe(EnforcingEntityAssociationLoader, () => { anything(), anything(), anything() as never, - anything(), ), ).resolves.toEqual([resolved]); }); @@ -241,17 +212,14 @@ describe(EnforcingEntityAssociationLoader, () => { mock>(); const rejection = new Error(); when( - nonEnforcingEntityAssociationLoaderMock.loadAssociatedEntityThroughAsync( - anything(), - anything(), - ), + nonEnforcingEntityAssociationLoaderMock.loadAssociatedEntityThroughAsync(anything()), ).thenResolve(result(rejection)); const nonEnforcingEntityAssociationLoader = instance(nonEnforcingEntityAssociationLoaderMock); const enforcingEntityAssociationLoader = new EnforcingEntityAssociationLoader( nonEnforcingEntityAssociationLoader, ); await expect( - enforcingEntityAssociationLoader.loadAssociatedEntityThroughAsync(anything(), anything()), + enforcingEntityAssociationLoader.loadAssociatedEntityThroughAsync(anything()), ).rejects.toThrow(rejection); }); @@ -260,17 +228,14 @@ describe(EnforcingEntityAssociationLoader, () => { mock>(); const resolved = {} as any; when( - nonEnforcingEntityAssociationLoaderMock.loadAssociatedEntityThroughAsync( - anything(), - anything(), - ), + nonEnforcingEntityAssociationLoaderMock.loadAssociatedEntityThroughAsync(anything()), ).thenResolve(result(resolved)); const nonEnforcingEntityAssociationLoader = instance(nonEnforcingEntityAssociationLoaderMock); const enforcingEntityLoader = new EnforcingEntityAssociationLoader( nonEnforcingEntityAssociationLoader, ); await expect( - enforcingEntityLoader.loadAssociatedEntityThroughAsync(anything(), anything()), + enforcingEntityLoader.loadAssociatedEntityThroughAsync(anything()), ).resolves.toEqual(resolved); }); });