@expo/entity 0.34.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/AuthorizationResultBasedEntityLoader.d.ts +128 -0
- package/build/AuthorizationResultBasedEntityLoader.js +196 -0
- package/build/AuthorizationResultBasedEntityLoader.js.map +1 -0
- package/build/ComposedEntityCacheAdapter.js +1 -0
- package/build/ComposedEntityCacheAdapter.js.map +1 -1
- package/build/ComposedSecondaryEntityCache.js +1 -0
- package/build/ComposedSecondaryEntityCache.js.map +1 -1
- package/build/EnforcingEntityLoader.d.ts +5 -4
- package/build/EnforcingEntityLoader.js +4 -2
- package/build/EnforcingEntityLoader.js.map +1 -1
- package/build/Entity.d.ts +4 -31
- package/build/Entity.js +19 -46
- package/build/Entity.js.map +1 -1
- package/build/EntityAssociationLoader.d.ts +9 -9
- package/build/EntityAssociationLoader.js +37 -12
- package/build/EntityAssociationLoader.js.map +1 -1
- package/build/EntityCompanion.js +9 -1
- package/build/EntityCompanion.js.map +1 -1
- package/build/EntityCompanionProvider.d.ts +3 -1
- package/build/EntityCompanionProvider.js +10 -4
- package/build/EntityCompanionProvider.js.map +1 -1
- package/build/EntityConfiguration.d.ts +2 -1
- package/build/EntityConfiguration.js +19 -1
- package/build/EntityConfiguration.js.map +1 -1
- package/build/EntityDatabaseAdapter.d.ts +2 -2
- package/build/EntityDatabaseAdapter.js +5 -3
- package/build/EntityDatabaseAdapter.js.map +1 -1
- package/build/EntityFieldDefinition.d.ts +21 -10
- package/build/EntityFieldDefinition.js +8 -9
- package/build/EntityFieldDefinition.js.map +1 -1
- package/build/EntityFields.d.ts +10 -0
- package/build/EntityFields.js +15 -1
- package/build/EntityFields.js.map +1 -1
- package/build/EntityLoader.d.ts +12 -125
- package/build/EntityLoader.js +24 -239
- package/build/EntityLoader.js.map +1 -1
- package/build/EntityLoaderFactory.d.ts +1 -1
- package/build/EntityLoaderFactory.js +3 -0
- package/build/EntityLoaderFactory.js.map +1 -1
- package/build/EntityLoaderUtils.d.ts +58 -0
- package/build/EntityLoaderUtils.js +109 -0
- package/build/EntityLoaderUtils.js.map +1 -0
- package/build/EntityMutator.d.ts +1 -0
- package/build/EntityMutator.js +71 -56
- package/build/EntityMutator.js.map +1 -1
- package/build/EntityMutatorFactory.js +9 -0
- package/build/EntityMutatorFactory.js.map +1 -1
- package/build/EntityPrivacyPolicy.d.ts +11 -5
- package/build/EntityPrivacyPolicy.js +5 -7
- package/build/EntityPrivacyPolicy.js.map +1 -1
- package/build/EntityQueryContext.d.ts +2 -1
- package/build/EntityQueryContext.js +11 -6
- package/build/EntityQueryContext.js.map +1 -1
- package/build/EntityQueryContextProvider.d.ts +1 -1
- package/build/EntityQueryContextProvider.js +1 -1
- package/build/EntityQueryContextProvider.js.map +1 -1
- package/build/EntitySecondaryCacheLoader.js +5 -1
- package/build/EntitySecondaryCacheLoader.js.map +1 -1
- package/build/GenericEntityCacheAdapter.js +1 -0
- package/build/GenericEntityCacheAdapter.js.map +1 -1
- package/build/GenericSecondaryEntityCache.js +2 -0
- package/build/GenericSecondaryEntityCache.js.map +1 -1
- package/build/IEntityCacheAdapterProvider.d.ts +1 -1
- package/build/IEntityDatabaseAdapterProvider.d.ts +1 -1
- package/build/ReadonlyEntity.d.ts +1 -1
- package/build/ReadonlyEntity.js +9 -2
- package/build/ReadonlyEntity.js.map +1 -1
- package/build/ViewerContext.d.ts +2 -2
- package/build/ViewerContext.js +5 -3
- package/build/ViewerContext.js.map +1 -1
- package/build/ViewerScopedEntityCompanion.js +2 -0
- package/build/ViewerScopedEntityCompanion.js.map +1 -1
- package/build/ViewerScopedEntityCompanionProvider.d.ts +0 -1
- package/build/ViewerScopedEntityCompanionProvider.js +2 -1
- package/build/ViewerScopedEntityCompanionProvider.js.map +1 -1
- package/build/ViewerScopedEntityLoaderFactory.d.ts +1 -1
- package/build/ViewerScopedEntityLoaderFactory.js +2 -0
- package/build/ViewerScopedEntityLoaderFactory.js.map +1 -1
- package/build/ViewerScopedEntityMutatorFactory.js +2 -0
- package/build/ViewerScopedEntityMutatorFactory.js.map +1 -1
- package/build/__tests__/ComposedCacheAdapter-test.js +2 -0
- package/build/__tests__/ComposedCacheAdapter-test.js.map +1 -1
- package/build/__tests__/ComposedSecondaryEntityCache-test.js +1 -0
- package/build/__tests__/ComposedSecondaryEntityCache-test.js.map +1 -1
- package/build/__tests__/EnforcingEntityLoader-test.js +101 -113
- package/build/__tests__/EnforcingEntityLoader-test.js.map +1 -1
- package/build/__tests__/Entity-test.js +5 -137
- package/build/__tests__/Entity-test.js.map +1 -1
- package/build/__tests__/EntityAssociationLoader-test.js +37 -65
- package/build/__tests__/EntityAssociationLoader-test.js.map +1 -1
- package/build/__tests__/EntityCommonUseCases-test.js +31 -37
- package/build/__tests__/EntityCommonUseCases-test.js.map +1 -1
- package/build/__tests__/EntityCompanion-test.js +26 -3
- package/build/__tests__/EntityCompanion-test.js.map +1 -1
- package/build/__tests__/EntityConfiguration-test.js +103 -0
- package/build/__tests__/EntityConfiguration-test.js.map +1 -0
- package/build/__tests__/EntityDatabaseAdapter-test.js +6 -0
- package/build/__tests__/EntityDatabaseAdapter-test.js.map +1 -1
- package/build/__tests__/EntityEdges-test.js +89 -80
- package/build/__tests__/EntityEdges-test.js.map +1 -1
- package/build/__tests__/EntityFields-test.js +6 -0
- package/build/__tests__/EntityFields-test.js.map +1 -1
- package/build/__tests__/EntityLoader-constructor-test.js +17 -18
- package/build/__tests__/EntityLoader-constructor-test.js.map +1 -1
- package/build/__tests__/EntityLoader-test.js +93 -41
- package/build/__tests__/EntityLoader-test.js.map +1 -1
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js +18 -21
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js.map +1 -1
- package/build/__tests__/EntityMutator-test.js +74 -29
- package/build/__tests__/EntityMutator-test.js.map +1 -1
- package/build/__tests__/EntityPrivacyPolicy-test.js +77 -59
- package/build/__tests__/EntityPrivacyPolicy-test.js.map +1 -1
- package/build/__tests__/EntityQueryContext-test.js +9 -0
- package/build/__tests__/EntityQueryContext-test.js.map +1 -1
- package/build/__tests__/EntitySecondaryCacheLoader-test.js +10 -10
- package/build/__tests__/EntitySecondaryCacheLoader-test.js.map +1 -1
- package/build/__tests__/EntitySelfReferentialEdges-test.js +59 -74
- package/build/__tests__/EntitySelfReferentialEdges-test.js.map +1 -1
- package/build/__tests__/ReadonlyEntity-test.js +13 -13
- package/build/__tests__/ReadonlyEntity-test.js.map +1 -1
- package/build/__tests__/ViewerContext-test.js +2 -2
- package/build/__tests__/ViewerContext-test.js.map +1 -1
- package/build/__tests__/ViewerScopedEntityLoaderFactory-test.js.map +1 -1
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js +26 -28
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js.map +1 -1
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js +25 -30
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js.map +1 -1
- package/build/entityUtils.d.ts +1 -1
- package/build/entityUtils.js.map +1 -1
- package/build/errors/EntityCacheAdapterError.js +2 -5
- package/build/errors/EntityCacheAdapterError.js.map +1 -1
- package/build/errors/EntityDatabaseAdapterError.js +14 -35
- package/build/errors/EntityDatabaseAdapterError.js.map +1 -1
- package/build/errors/EntityError.js +1 -0
- package/build/errors/EntityError.js.map +1 -1
- package/build/errors/EntityInvalidFieldValueError.js +2 -2
- package/build/errors/EntityInvalidFieldValueError.js.map +1 -1
- package/build/errors/EntityNotAuthorizedError.js +3 -2
- package/build/errors/EntityNotAuthorizedError.js.map +1 -1
- package/build/errors/EntityNotFoundError.js +2 -2
- package/build/errors/EntityNotFoundError.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/internal/EntityDataManager.d.ts +1 -1
- package/build/internal/EntityDataManager.js +7 -2
- package/build/internal/EntityDataManager.js.map +1 -1
- package/build/internal/EntityFieldTransformationUtils.d.ts +5 -5
- package/build/internal/EntityFieldTransformationUtils.js +5 -8
- package/build/internal/EntityFieldTransformationUtils.js.map +1 -1
- package/build/internal/EntityTableDataCoordinator.d.ts +1 -1
- package/build/internal/EntityTableDataCoordinator.js +5 -0
- package/build/internal/EntityTableDataCoordinator.js.map +1 -1
- package/build/internal/ReadThroughEntityCache.d.ts +1 -1
- package/build/internal/ReadThroughEntityCache.js +2 -0
- package/build/internal/ReadThroughEntityCache.js.map +1 -1
- package/build/internal/__tests__/EntityDataManager-test.js +11 -11
- package/build/internal/__tests__/EntityDataManager-test.js.map +1 -1
- package/build/internal/__tests__/EntityFieldTransformationUtils-test.js +6 -2
- package/build/internal/__tests__/EntityFieldTransformationUtils-test.js.map +1 -1
- package/build/internal/__tests__/ReadThroughEntityCache-test.js +33 -0
- package/build/internal/__tests__/ReadThroughEntityCache-test.js.map +1 -1
- package/build/metrics/IEntityMetricsAdapter.d.ts +1 -1
- package/build/rules/AlwaysAllowPrivacyPolicyRule.d.ts +1 -1
- package/build/rules/AlwaysAllowPrivacyPolicyRule.js.map +1 -1
- package/build/rules/AlwaysDenyPrivacyPolicyRule.d.ts +1 -1
- package/build/rules/AlwaysDenyPrivacyPolicyRule.js.map +1 -1
- package/build/rules/AlwaysSkipPrivacyPolicyRule.d.ts +1 -1
- package/build/rules/AlwaysSkipPrivacyPolicyRule.js.map +1 -1
- package/build/rules/PrivacyPolicyRule.d.ts +1 -1
- package/build/rules/PrivacyPolicyRule.js.map +1 -1
- package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.js.map +1 -1
- package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.js.map +1 -1
- package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.js.map +1 -1
- package/build/testfixtures/DateIDTestEntity.js +12 -15
- package/build/testfixtures/DateIDTestEntity.js.map +1 -1
- package/build/testfixtures/SimpleTestEntity.d.ts +8 -8
- package/build/testfixtures/SimpleTestEntity.js +12 -15
- package/build/testfixtures/SimpleTestEntity.js.map +1 -1
- package/build/testfixtures/TestEntity.d.ts +12 -12
- package/build/testfixtures/TestEntity.js +12 -15
- package/build/testfixtures/TestEntity.js.map +1 -1
- package/build/testfixtures/TestEntity2.d.ts +8 -8
- package/build/testfixtures/TestEntity2.js +12 -15
- package/build/testfixtures/TestEntity2.js.map +1 -1
- package/build/testfixtures/TestEntityNumberKey.js +12 -15
- package/build/testfixtures/TestEntityNumberKey.js.map +1 -1
- package/build/testfixtures/TestEntityWithMutationTriggers.d.ts +36 -0
- package/build/testfixtures/TestEntityWithMutationTriggers.js +82 -0
- package/build/testfixtures/TestEntityWithMutationTriggers.js.map +1 -0
- package/build/testfixtures/TestViewerContext.d.ts +0 -3
- package/build/testfixtures/TestViewerContext.js +0 -6
- package/build/testfixtures/TestViewerContext.js.map +1 -1
- package/build/utils/EntityPrivacyUtils.d.ts +34 -0
- package/build/utils/EntityPrivacyUtils.js +160 -0
- package/build/utils/EntityPrivacyUtils.js.map +1 -0
- package/build/utils/__tests__/EntityPrivacyUtils-test.d.ts +1 -0
- package/build/utils/__tests__/EntityPrivacyUtils-test.js +395 -0
- package/build/utils/__tests__/EntityPrivacyUtils-test.js.map +1 -0
- package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.d.ts +1 -0
- package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.js +26 -0
- package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.js.map +1 -0
- package/build/utils/collections/maps.js.map +1 -1
- package/build/utils/mergeEntityMutationTriggerConfigurations.d.ts +4 -0
- package/build/utils/mergeEntityMutationTriggerConfigurations.js +28 -0
- package/build/utils/mergeEntityMutationTriggerConfigurations.js.map +1 -0
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.d.ts +1 -1
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.js.map +1 -1
- package/build/utils/testing/StubCacheAdapter.d.ts +3 -3
- package/build/utils/testing/StubCacheAdapter.js +3 -3
- package/build/utils/testing/StubCacheAdapter.js.map +1 -1
- package/build/utils/testing/StubDatabaseAdapter.d.ts +2 -2
- package/build/utils/testing/StubDatabaseAdapter.js +4 -2
- package/build/utils/testing/StubDatabaseAdapter.js.map +1 -1
- package/build/utils/testing/StubDatabaseAdapterProvider.d.ts +1 -1
- package/build/utils/testing/StubDatabaseAdapterProvider.js +1 -3
- package/build/utils/testing/StubDatabaseAdapterProvider.js.map +1 -1
- package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.d.ts +1 -0
- package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.js +42 -0
- package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.js.map +1 -0
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.js +53 -0
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.js.map +1 -1
- package/build/utils/testing/describeFieldTestCase.js.map +1 -1
- package/package.json +4 -3
- package/src/AuthorizationResultBasedEntityLoader.ts +297 -0
- package/src/ComposedEntityCacheAdapter.ts +6 -6
- package/src/ComposedSecondaryEntityCache.ts +8 -8
- package/src/EnforcingEntityLoader.ts +20 -19
- package/src/Entity.ts +26 -118
- package/src/EntityAssociationLoader.ts +56 -41
- package/src/EntityCompanion.ts +8 -4
- package/src/EntityCompanionProvider.ts +24 -16
- package/src/EntityConfiguration.ts +18 -7
- package/src/EntityDatabaseAdapter.ts +41 -41
- package/src/EntityFieldDefinition.ts +28 -18
- package/src/EntityFields.ts +15 -0
- package/src/EntityLoader.ts +63 -357
- package/src/EntityLoaderFactory.ts +10 -4
- package/src/EntityLoaderUtils.ts +149 -0
- package/src/EntityMutationInfo.ts +2 -2
- package/src/EntityMutationTriggerConfiguration.ts +5 -5
- package/src/EntityMutationValidator.ts +2 -2
- package/src/EntityMutator.ts +146 -144
- package/src/EntityMutatorFactory.ts +8 -8
- package/src/EntityPrivacyPolicy.ts +78 -28
- package/src/EntityQueryContext.ts +14 -13
- package/src/EntityQueryContextProvider.ts +6 -6
- package/src/EntitySecondaryCacheLoader.ts +13 -11
- package/src/GenericEntityCacheAdapter.ts +10 -10
- package/src/GenericSecondaryEntityCache.ts +6 -6
- package/src/IEntityCacheAdapter.ts +4 -4
- package/src/IEntityCacheAdapterProvider.ts +2 -2
- package/src/IEntityDatabaseAdapterProvider.ts +2 -2
- package/src/ReadonlyEntity.ts +8 -5
- package/src/ViewerContext.ts +10 -10
- package/src/ViewerScopedEntityCompanion.ts +4 -4
- package/src/ViewerScopedEntityCompanionProvider.ts +4 -5
- package/src/ViewerScopedEntityLoaderFactory.ts +10 -4
- package/src/ViewerScopedEntityMutatorFactory.ts +5 -5
- package/src/__tests__/ComposedCacheAdapter-test.ts +12 -10
- package/src/__tests__/ComposedSecondaryEntityCache-test.ts +8 -8
- package/src/__tests__/EnforcingEntityLoader-test.ts +236 -159
- package/src/__tests__/Entity-test.ts +5 -223
- package/src/__tests__/EntityAssociationLoader-test.ts +91 -169
- package/src/__tests__/EntityCommonUseCases-test.ts +36 -38
- package/src/__tests__/EntityCompanion-test.ts +57 -5
- package/src/__tests__/EntityConfiguration-test.ts +118 -0
- package/src/__tests__/EntityDatabaseAdapter-test.ts +11 -11
- package/src/__tests__/EntityEdges-test.ts +128 -118
- package/src/__tests__/EntityFields-test.ts +14 -2
- package/src/__tests__/EntityLoader-constructor-test.ts +21 -8
- package/src/__tests__/EntityLoader-test.ts +233 -105
- package/src/__tests__/EntityMutator-MutationCacheConsistency-test.ts +17 -20
- package/src/__tests__/EntityMutator-test.ts +342 -163
- package/src/__tests__/EntityPrivacyPolicy-test.ts +166 -53
- package/src/__tests__/EntityQueryContext-test.ts +30 -12
- package/src/__tests__/EntitySecondaryCacheLoader-test.ts +17 -26
- package/src/__tests__/EntitySelfReferentialEdges-test.ts +67 -115
- package/src/__tests__/GenericEntityCacheAdapter-test.ts +2 -2
- package/src/__tests__/ReadonlyEntity-test.ts +13 -15
- package/src/__tests__/ViewerContext-test.ts +3 -4
- package/src/__tests__/ViewerScopedEntityCompanion-test.ts +2 -2
- package/src/__tests__/ViewerScopedEntityCompanionProvider-test.ts +2 -2
- package/src/__tests__/ViewerScopedEntityLoaderFactory-test.ts +2 -1
- package/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts +34 -45
- package/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts +22 -30
- package/src/__tests__/entityUtils-test.ts +2 -2
- package/src/entityUtils.ts +4 -4
- package/src/errors/EntityError.ts +4 -1
- package/src/errors/EntityInvalidFieldValueError.ts +2 -2
- package/src/errors/EntityNotAuthorizedError.ts +3 -3
- package/src/errors/EntityNotFoundError.ts +2 -2
- package/src/index.ts +1 -0
- package/src/internal/EntityDataManager.ts +25 -25
- package/src/internal/EntityFieldTransformationUtils.ts +39 -32
- package/src/internal/EntityTableDataCoordinator.ts +3 -3
- package/src/internal/ReadThroughEntityCache.ts +9 -9
- package/src/internal/__tests__/EntityDataManager-test.ts +62 -62
- package/src/internal/__tests__/EntityFieldTransformationUtils-test.ts +14 -10
- package/src/internal/__tests__/ReadThroughEntityCache-test.ts +74 -18
- package/src/metrics/EntityMetricsUtils.ts +4 -4
- package/src/metrics/IEntityMetricsAdapter.ts +1 -1
- package/src/rules/AlwaysAllowPrivacyPolicyRule.ts +9 -3
- package/src/rules/AlwaysDenyPrivacyPolicyRule.ts +9 -3
- package/src/rules/AlwaysSkipPrivacyPolicyRule.ts +9 -3
- package/src/rules/PrivacyPolicyRule.ts +9 -3
- package/src/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.ts +2 -1
- package/src/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.ts +2 -1
- package/src/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.ts +2 -1
- package/src/testfixtures/SimpleTestEntity.ts +8 -8
- package/src/testfixtures/TestEntity.ts +13 -16
- package/src/testfixtures/TestEntity2.ts +8 -8
- package/src/testfixtures/TestEntityWithMutationTriggers.ts +156 -0
- package/src/testfixtures/TestViewerContext.ts +1 -12
- package/src/utils/EntityPrivacyUtils.ts +325 -0
- package/src/utils/__tests__/EntityPrivacyUtils-test.ts +570 -0
- package/src/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.ts +29 -0
- package/src/utils/collections/__tests__/maps-test.ts +2 -2
- package/src/utils/collections/maps.ts +11 -11
- package/src/utils/mergeEntityMutationTriggerConfigurations.ts +44 -0
- package/src/utils/testing/PrivacyPolicyRuleTestUtils.ts +25 -22
- package/src/utils/testing/StubCacheAdapter.ts +17 -15
- package/src/utils/testing/StubDatabaseAdapter.ts +35 -30
- package/src/utils/testing/StubDatabaseAdapterProvider.ts +2 -2
- package/src/utils/testing/StubQueryContextProvider.ts +2 -2
- package/src/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.ts +42 -0
- package/src/utils/testing/__tests__/StubDatabaseAdapter-test.ts +111 -29
- package/src/utils/testing/createUnitTestEntityCompanionProvider.ts +2 -2
- package/src/utils/testing/describeFieldTestCase.ts +1 -1
- package/build/__tests__/EntityDataConfiguration-test.js +0 -68
- package/build/__tests__/EntityDataConfiguration-test.js.map +0 -1
- package/src/__tests__/EntityDataConfiguration-test.ts +0 -77
- /package/build/__tests__/{EntityDataConfiguration-test.d.ts → EntityConfiguration-test.d.ts} +0 -0
|
@@ -1,384 +1,461 @@
|
|
|
1
1
|
import { result } from '@expo/results';
|
|
2
2
|
import { mock, instance, when, anything } from 'ts-mockito';
|
|
3
3
|
|
|
4
|
+
import AuthorizationResultBasedEntityLoader from '../AuthorizationResultBasedEntityLoader';
|
|
4
5
|
import EnforcingEntityLoader from '../EnforcingEntityLoader';
|
|
5
|
-
import EntityLoader from '../EntityLoader';
|
|
6
6
|
|
|
7
7
|
describe(EnforcingEntityLoader, () => {
|
|
8
8
|
describe('loadManyByFieldEqualingManyAsync', () => {
|
|
9
9
|
it('throws when result is unsuccessful', async () => {
|
|
10
|
-
const
|
|
10
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
11
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
12
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
11
13
|
const rejection = new Error();
|
|
12
|
-
when(
|
|
14
|
+
when(
|
|
15
|
+
nonEnforcingEntityLoaderMock.loadManyByFieldEqualingManyAsync(anything(), anything()),
|
|
16
|
+
).thenResolve(
|
|
13
17
|
new Map(
|
|
14
18
|
Object.entries({
|
|
15
19
|
hello: [result(rejection)],
|
|
16
|
-
})
|
|
17
|
-
)
|
|
20
|
+
}),
|
|
21
|
+
),
|
|
18
22
|
);
|
|
19
|
-
const
|
|
20
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
23
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
24
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
21
25
|
await expect(
|
|
22
|
-
enforcingEntityLoader.loadManyByFieldEqualingManyAsync(anything(), anything())
|
|
26
|
+
enforcingEntityLoader.loadManyByFieldEqualingManyAsync(anything(), anything()),
|
|
23
27
|
).rejects.toThrow(rejection);
|
|
24
28
|
});
|
|
25
29
|
|
|
26
30
|
it('returns value when result is successful', async () => {
|
|
27
|
-
const
|
|
31
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
32
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
33
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
28
34
|
const resolved = {};
|
|
29
|
-
when(
|
|
35
|
+
when(
|
|
36
|
+
nonEnforcingEntityLoaderMock.loadManyByFieldEqualingManyAsync(anything(), anything()),
|
|
37
|
+
).thenResolve(
|
|
30
38
|
new Map(
|
|
31
39
|
Object.entries({
|
|
32
40
|
hello: [result(resolved)],
|
|
33
|
-
})
|
|
34
|
-
)
|
|
41
|
+
}),
|
|
42
|
+
),
|
|
35
43
|
);
|
|
36
|
-
const
|
|
37
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
44
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
45
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
38
46
|
await expect(
|
|
39
|
-
enforcingEntityLoader.loadManyByFieldEqualingManyAsync(anything(), anything())
|
|
47
|
+
enforcingEntityLoader.loadManyByFieldEqualingManyAsync(anything(), anything()),
|
|
40
48
|
).resolves.toEqual(
|
|
41
49
|
new Map(
|
|
42
50
|
Object.entries({
|
|
43
51
|
hello: [resolved],
|
|
44
|
-
})
|
|
45
|
-
)
|
|
52
|
+
}),
|
|
53
|
+
),
|
|
46
54
|
);
|
|
47
55
|
});
|
|
48
56
|
});
|
|
49
57
|
|
|
50
58
|
describe('loadManyByFieldEqualingAsync', () => {
|
|
51
59
|
it('throws when result is unsuccessful', async () => {
|
|
52
|
-
const
|
|
60
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
61
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
62
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
53
63
|
const rejection = new Error();
|
|
54
|
-
when(
|
|
55
|
-
|
|
56
|
-
]);
|
|
57
|
-
const
|
|
58
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
64
|
+
when(
|
|
65
|
+
nonEnforcingEntityLoaderMock.loadManyByFieldEqualingAsync(anything(), anything()),
|
|
66
|
+
).thenResolve([result(rejection)]);
|
|
67
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
68
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
59
69
|
await expect(
|
|
60
|
-
enforcingEntityLoader.loadManyByFieldEqualingAsync(anything(), anything())
|
|
70
|
+
enforcingEntityLoader.loadManyByFieldEqualingAsync(anything(), anything()),
|
|
61
71
|
).rejects.toThrow(rejection);
|
|
62
72
|
});
|
|
63
73
|
|
|
64
74
|
it('returns value when result is successful', async () => {
|
|
65
|
-
const
|
|
75
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
76
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
77
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
66
78
|
const resolved = {};
|
|
67
|
-
when(
|
|
68
|
-
|
|
69
|
-
]);
|
|
70
|
-
const
|
|
71
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
79
|
+
when(
|
|
80
|
+
nonEnforcingEntityLoaderMock.loadManyByFieldEqualingAsync(anything(), anything()),
|
|
81
|
+
).thenResolve([result(resolved)]);
|
|
82
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
83
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
72
84
|
await expect(
|
|
73
|
-
enforcingEntityLoader.loadManyByFieldEqualingAsync(anything(), anything())
|
|
85
|
+
enforcingEntityLoader.loadManyByFieldEqualingAsync(anything(), anything()),
|
|
74
86
|
).resolves.toEqual([resolved]);
|
|
75
87
|
});
|
|
76
88
|
});
|
|
77
89
|
|
|
78
90
|
describe('loadByFieldEqualingAsync', () => {
|
|
79
91
|
it('throws when result is unsuccessful', async () => {
|
|
80
|
-
const
|
|
92
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
93
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
94
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
81
95
|
const rejection = new Error();
|
|
82
|
-
when(
|
|
83
|
-
|
|
84
|
-
);
|
|
85
|
-
const
|
|
86
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
96
|
+
when(
|
|
97
|
+
nonEnforcingEntityLoaderMock.loadByFieldEqualingAsync(anything(), anything()),
|
|
98
|
+
).thenResolve(result(rejection));
|
|
99
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
100
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
87
101
|
await expect(
|
|
88
|
-
enforcingEntityLoader.loadByFieldEqualingAsync(anything(), anything())
|
|
102
|
+
enforcingEntityLoader.loadByFieldEqualingAsync(anything(), anything()),
|
|
89
103
|
).rejects.toThrow(rejection);
|
|
90
104
|
});
|
|
91
105
|
|
|
92
106
|
it('returns value when result is successful', async () => {
|
|
93
|
-
const
|
|
107
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
108
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
109
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
94
110
|
const resolved = {};
|
|
95
|
-
when(
|
|
96
|
-
|
|
97
|
-
);
|
|
98
|
-
const
|
|
99
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
111
|
+
when(
|
|
112
|
+
nonEnforcingEntityLoaderMock.loadByFieldEqualingAsync(anything(), anything()),
|
|
113
|
+
).thenResolve(result(resolved));
|
|
114
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
115
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
100
116
|
await expect(
|
|
101
|
-
enforcingEntityLoader.loadByFieldEqualingAsync(anything(), anything())
|
|
117
|
+
enforcingEntityLoader.loadByFieldEqualingAsync(anything(), anything()),
|
|
102
118
|
).resolves.toEqual(resolved);
|
|
103
119
|
});
|
|
104
120
|
|
|
105
121
|
it('returns null when result is successful and no entity is found', async () => {
|
|
106
|
-
const
|
|
122
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
123
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
124
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
107
125
|
const resolved = null;
|
|
108
|
-
when(
|
|
109
|
-
|
|
110
|
-
);
|
|
111
|
-
const
|
|
112
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
126
|
+
when(
|
|
127
|
+
nonEnforcingEntityLoaderMock.loadByFieldEqualingAsync(anything(), anything()),
|
|
128
|
+
).thenResolve(result(resolved));
|
|
129
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
130
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
113
131
|
await expect(
|
|
114
|
-
enforcingEntityLoader.loadByFieldEqualingAsync(anything(), anything())
|
|
132
|
+
enforcingEntityLoader.loadByFieldEqualingAsync(anything(), anything()),
|
|
115
133
|
).resolves.toEqual(resolved);
|
|
116
134
|
});
|
|
117
135
|
|
|
118
136
|
it('throws when multiple matching entities are found', async () => {
|
|
119
|
-
const
|
|
137
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
138
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
139
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
120
140
|
const multipleEntitiesError = new Error();
|
|
121
|
-
when(
|
|
122
|
-
|
|
123
|
-
);
|
|
124
|
-
const
|
|
125
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
141
|
+
when(
|
|
142
|
+
nonEnforcingEntityLoaderMock.loadByFieldEqualingAsync(anything(), anything()),
|
|
143
|
+
).thenReject(multipleEntitiesError);
|
|
144
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
145
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
126
146
|
await expect(
|
|
127
|
-
enforcingEntityLoader.loadByFieldEqualingAsync(anything(), anything())
|
|
147
|
+
enforcingEntityLoader.loadByFieldEqualingAsync(anything(), anything()),
|
|
128
148
|
).rejects.toEqual(multipleEntitiesError);
|
|
129
149
|
});
|
|
130
150
|
});
|
|
131
151
|
|
|
132
152
|
describe('loadByIDAsync', () => {
|
|
133
153
|
it('throws when result is unsuccessful', async () => {
|
|
134
|
-
const
|
|
154
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
155
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
156
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
135
157
|
const rejection = new Error();
|
|
136
|
-
when(
|
|
137
|
-
const
|
|
138
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
158
|
+
when(nonEnforcingEntityLoaderMock.loadByIDAsync(anything())).thenResolve(result(rejection));
|
|
159
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
160
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
139
161
|
await expect(enforcingEntityLoader.loadByIDAsync(anything())).rejects.toThrow(rejection);
|
|
140
162
|
});
|
|
141
163
|
|
|
142
164
|
it('returns value when result is successful', async () => {
|
|
143
|
-
const
|
|
165
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
166
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
167
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
144
168
|
const resolved = {};
|
|
145
|
-
when(
|
|
146
|
-
const
|
|
147
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
169
|
+
when(nonEnforcingEntityLoaderMock.loadByIDAsync(anything())).thenResolve(result(resolved));
|
|
170
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
171
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
148
172
|
await expect(enforcingEntityLoader.loadByIDAsync(anything())).resolves.toEqual(resolved);
|
|
149
173
|
});
|
|
150
174
|
});
|
|
151
175
|
|
|
152
176
|
describe('loadByIDNullableAsync', () => {
|
|
153
177
|
it('throws when result is unsuccessful', async () => {
|
|
154
|
-
const
|
|
178
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
179
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
180
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
155
181
|
const rejection = new Error();
|
|
156
|
-
when(
|
|
157
|
-
|
|
158
|
-
|
|
182
|
+
when(nonEnforcingEntityLoaderMock.loadByIDNullableAsync(anything())).thenResolve(
|
|
183
|
+
result(rejection),
|
|
184
|
+
);
|
|
185
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
186
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
159
187
|
await expect(enforcingEntityLoader.loadByIDNullableAsync(anything())).rejects.toThrow(
|
|
160
|
-
rejection
|
|
188
|
+
rejection,
|
|
161
189
|
);
|
|
162
190
|
});
|
|
163
191
|
|
|
164
192
|
it('returns value when result is successful', async () => {
|
|
165
|
-
const
|
|
193
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
194
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
195
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
166
196
|
const resolved = {};
|
|
167
|
-
when(
|
|
168
|
-
|
|
169
|
-
|
|
197
|
+
when(nonEnforcingEntityLoaderMock.loadByIDNullableAsync(anything())).thenResolve(
|
|
198
|
+
result(resolved),
|
|
199
|
+
);
|
|
200
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
201
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
170
202
|
await expect(enforcingEntityLoader.loadByIDNullableAsync(anything())).resolves.toEqual(
|
|
171
|
-
resolved
|
|
203
|
+
resolved,
|
|
172
204
|
);
|
|
173
205
|
});
|
|
174
206
|
|
|
175
207
|
it('returns null when non-existent object', async () => {
|
|
176
|
-
const
|
|
208
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
209
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
210
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
177
211
|
const resolved = null;
|
|
178
|
-
when(
|
|
179
|
-
|
|
180
|
-
|
|
212
|
+
when(nonEnforcingEntityLoaderMock.loadByIDNullableAsync(anything())).thenResolve(
|
|
213
|
+
result(resolved),
|
|
214
|
+
);
|
|
215
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
216
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
181
217
|
await expect(enforcingEntityLoader.loadByIDNullableAsync(anything())).resolves.toEqual(
|
|
182
|
-
resolved
|
|
218
|
+
resolved,
|
|
183
219
|
);
|
|
184
220
|
});
|
|
185
221
|
});
|
|
186
222
|
|
|
187
223
|
describe('loadManyByIDsAsync', () => {
|
|
188
224
|
it('throws when result is unsuccessful', async () => {
|
|
189
|
-
const
|
|
225
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
226
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
227
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
190
228
|
const rejection = new Error();
|
|
191
|
-
when(
|
|
229
|
+
when(nonEnforcingEntityLoaderMock.loadManyByIDsAsync(anything())).thenResolve(
|
|
192
230
|
new Map(
|
|
193
231
|
Object.entries({
|
|
194
232
|
hello: result(rejection),
|
|
195
|
-
})
|
|
196
|
-
)
|
|
233
|
+
}),
|
|
234
|
+
),
|
|
197
235
|
);
|
|
198
|
-
const
|
|
199
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
236
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
237
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
200
238
|
await expect(enforcingEntityLoader.loadManyByIDsAsync(anything())).rejects.toThrow(rejection);
|
|
201
239
|
});
|
|
202
240
|
|
|
203
241
|
it('returns value when result is successful', async () => {
|
|
204
|
-
const
|
|
242
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
243
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
244
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
205
245
|
const resolved = {};
|
|
206
|
-
when(
|
|
246
|
+
when(nonEnforcingEntityLoaderMock.loadManyByIDsAsync(anything())).thenResolve(
|
|
207
247
|
new Map(
|
|
208
248
|
Object.entries({
|
|
209
249
|
hello: result(resolved),
|
|
210
|
-
})
|
|
211
|
-
)
|
|
250
|
+
}),
|
|
251
|
+
),
|
|
212
252
|
);
|
|
213
|
-
const
|
|
214
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
253
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
254
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
215
255
|
await expect(enforcingEntityLoader.loadManyByIDsAsync(anything())).resolves.toEqual(
|
|
216
256
|
new Map(
|
|
217
257
|
Object.entries({
|
|
218
258
|
hello: resolved,
|
|
219
|
-
})
|
|
220
|
-
)
|
|
259
|
+
}),
|
|
260
|
+
),
|
|
221
261
|
);
|
|
222
262
|
});
|
|
223
263
|
});
|
|
224
264
|
|
|
225
265
|
describe('loadManyByIDsNullableAsync', () => {
|
|
226
266
|
it('throws when result is unsuccessful even when there is a null result', async () => {
|
|
227
|
-
const
|
|
267
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
268
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
269
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
228
270
|
const rejection = new Error();
|
|
229
|
-
when(
|
|
271
|
+
when(nonEnforcingEntityLoaderMock.loadManyByIDsNullableAsync(anything())).thenResolve(
|
|
230
272
|
new Map(
|
|
231
273
|
Object.entries({
|
|
232
274
|
hello: result(rejection),
|
|
233
275
|
world: null,
|
|
234
|
-
})
|
|
235
|
-
)
|
|
276
|
+
}),
|
|
277
|
+
),
|
|
236
278
|
);
|
|
237
|
-
const
|
|
238
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
279
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
280
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
239
281
|
await expect(enforcingEntityLoader.loadManyByIDsNullableAsync(anything())).rejects.toThrow(
|
|
240
|
-
rejection
|
|
282
|
+
rejection,
|
|
241
283
|
);
|
|
242
284
|
});
|
|
243
285
|
|
|
244
286
|
it('returns value when result is successful', async () => {
|
|
245
|
-
const
|
|
287
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
288
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
289
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
246
290
|
const resolved = {};
|
|
247
|
-
when(
|
|
291
|
+
when(nonEnforcingEntityLoaderMock.loadManyByIDsNullableAsync(anything())).thenResolve(
|
|
248
292
|
new Map(
|
|
249
293
|
Object.entries({
|
|
250
294
|
hello: result(resolved),
|
|
251
295
|
world: null,
|
|
252
|
-
})
|
|
253
|
-
)
|
|
296
|
+
}),
|
|
297
|
+
),
|
|
254
298
|
);
|
|
255
|
-
const
|
|
256
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
299
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
300
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
257
301
|
await expect(enforcingEntityLoader.loadManyByIDsNullableAsync(anything())).resolves.toEqual(
|
|
258
302
|
new Map(
|
|
259
303
|
Object.entries({
|
|
260
304
|
hello: resolved,
|
|
261
305
|
world: null,
|
|
262
|
-
})
|
|
263
|
-
)
|
|
306
|
+
}),
|
|
307
|
+
),
|
|
264
308
|
);
|
|
265
309
|
});
|
|
266
310
|
});
|
|
267
311
|
|
|
268
312
|
describe('loadFirstByFieldEqualityConjunction', () => {
|
|
269
313
|
it('throws when result is unsuccessful', async () => {
|
|
270
|
-
const
|
|
314
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
315
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
316
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
271
317
|
const rejection = new Error();
|
|
272
318
|
when(
|
|
273
|
-
|
|
319
|
+
nonEnforcingEntityLoaderMock.loadFirstByFieldEqualityConjunctionAsync(
|
|
320
|
+
anything(),
|
|
321
|
+
anything(),
|
|
322
|
+
),
|
|
274
323
|
).thenResolve(result(rejection));
|
|
275
|
-
const
|
|
276
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
324
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
325
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
277
326
|
await expect(
|
|
278
|
-
enforcingEntityLoader.loadFirstByFieldEqualityConjunctionAsync(anything(), anything())
|
|
327
|
+
enforcingEntityLoader.loadFirstByFieldEqualityConjunctionAsync(anything(), anything()),
|
|
279
328
|
).rejects.toThrow(rejection);
|
|
280
329
|
});
|
|
281
330
|
|
|
282
331
|
it('returns value when result is successful', async () => {
|
|
283
|
-
const
|
|
332
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
333
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
334
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
284
335
|
const resolved = {};
|
|
285
336
|
when(
|
|
286
|
-
|
|
337
|
+
nonEnforcingEntityLoaderMock.loadFirstByFieldEqualityConjunctionAsync(
|
|
338
|
+
anything(),
|
|
339
|
+
anything(),
|
|
340
|
+
),
|
|
287
341
|
).thenResolve(result(resolved));
|
|
288
|
-
const
|
|
289
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
342
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
343
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
290
344
|
await expect(
|
|
291
|
-
enforcingEntityLoader.loadFirstByFieldEqualityConjunctionAsync(anything(), anything())
|
|
345
|
+
enforcingEntityLoader.loadFirstByFieldEqualityConjunctionAsync(anything(), anything()),
|
|
292
346
|
).resolves.toEqual(resolved);
|
|
293
347
|
});
|
|
294
348
|
|
|
295
349
|
it('returns null when the query is successful but no rows match', async () => {
|
|
296
|
-
const
|
|
350
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
351
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
352
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
297
353
|
when(
|
|
298
|
-
|
|
354
|
+
nonEnforcingEntityLoaderMock.loadFirstByFieldEqualityConjunctionAsync(
|
|
355
|
+
anything(),
|
|
356
|
+
anything(),
|
|
357
|
+
),
|
|
299
358
|
).thenResolve(null);
|
|
300
|
-
const
|
|
301
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
359
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
360
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
302
361
|
await expect(
|
|
303
|
-
enforcingEntityLoader.loadFirstByFieldEqualityConjunctionAsync(anything(), anything())
|
|
362
|
+
enforcingEntityLoader.loadFirstByFieldEqualityConjunctionAsync(anything(), anything()),
|
|
304
363
|
).resolves.toBeNull();
|
|
305
364
|
});
|
|
306
365
|
});
|
|
307
366
|
|
|
308
367
|
describe('loadManyByFieldEqualityConjunction', () => {
|
|
309
368
|
it('throws when result is unsuccessful', async () => {
|
|
310
|
-
const
|
|
369
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
370
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
371
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
311
372
|
const rejection = new Error();
|
|
312
373
|
when(
|
|
313
|
-
|
|
374
|
+
nonEnforcingEntityLoaderMock.loadManyByFieldEqualityConjunctionAsync(
|
|
375
|
+
anything(),
|
|
376
|
+
anything(),
|
|
377
|
+
),
|
|
314
378
|
).thenResolve([result(rejection)]);
|
|
315
|
-
const
|
|
316
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
379
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
380
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
317
381
|
await expect(
|
|
318
|
-
enforcingEntityLoader.loadManyByFieldEqualityConjunctionAsync(anything(), anything())
|
|
382
|
+
enforcingEntityLoader.loadManyByFieldEqualityConjunctionAsync(anything(), anything()),
|
|
319
383
|
).rejects.toThrow(rejection);
|
|
320
384
|
});
|
|
321
385
|
|
|
322
386
|
it('returns value when result is successful', async () => {
|
|
323
|
-
const
|
|
387
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
388
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
389
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
324
390
|
const resolved = {};
|
|
325
391
|
when(
|
|
326
|
-
|
|
392
|
+
nonEnforcingEntityLoaderMock.loadManyByFieldEqualityConjunctionAsync(
|
|
393
|
+
anything(),
|
|
394
|
+
anything(),
|
|
395
|
+
),
|
|
327
396
|
).thenResolve([result(resolved)]);
|
|
328
|
-
const
|
|
329
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
397
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
398
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
330
399
|
await expect(
|
|
331
|
-
enforcingEntityLoader.loadManyByFieldEqualityConjunctionAsync(anything(), anything())
|
|
400
|
+
enforcingEntityLoader.loadManyByFieldEqualityConjunctionAsync(anything(), anything()),
|
|
332
401
|
).resolves.toEqual([resolved]);
|
|
333
402
|
});
|
|
334
403
|
});
|
|
335
404
|
|
|
336
405
|
describe('loadManyByRawWhereClause', () => {
|
|
337
406
|
it('throws when result is unsuccessful', async () => {
|
|
338
|
-
const
|
|
407
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
408
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
409
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
339
410
|
const rejection = new Error();
|
|
340
411
|
when(
|
|
341
|
-
|
|
412
|
+
nonEnforcingEntityLoaderMock.loadManyByRawWhereClauseAsync(
|
|
413
|
+
anything(),
|
|
414
|
+
anything(),
|
|
415
|
+
anything(),
|
|
416
|
+
),
|
|
342
417
|
).thenResolve([result(rejection)]);
|
|
343
|
-
const
|
|
344
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
418
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
419
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
345
420
|
await expect(
|
|
346
|
-
enforcingEntityLoader.loadManyByRawWhereClauseAsync(anything(), anything(), anything())
|
|
421
|
+
enforcingEntityLoader.loadManyByRawWhereClauseAsync(anything(), anything(), anything()),
|
|
347
422
|
).rejects.toThrow(rejection);
|
|
348
423
|
});
|
|
349
424
|
|
|
350
425
|
it('returns value when result is successful', async () => {
|
|
351
|
-
const
|
|
426
|
+
const nonEnforcingEntityLoaderMock = mock<
|
|
427
|
+
AuthorizationResultBasedEntityLoader<any, any, any, any, any, any>
|
|
428
|
+
>(AuthorizationResultBasedEntityLoader);
|
|
352
429
|
const resolved = {};
|
|
353
430
|
when(
|
|
354
|
-
|
|
431
|
+
nonEnforcingEntityLoaderMock.loadManyByRawWhereClauseAsync(
|
|
432
|
+
anything(),
|
|
433
|
+
anything(),
|
|
434
|
+
anything(),
|
|
435
|
+
),
|
|
355
436
|
).thenResolve([result(resolved)]);
|
|
356
|
-
const
|
|
357
|
-
const enforcingEntityLoader = new EnforcingEntityLoader(
|
|
437
|
+
const nonEnforcingEntityLoader = instance(nonEnforcingEntityLoaderMock);
|
|
438
|
+
const enforcingEntityLoader = new EnforcingEntityLoader(nonEnforcingEntityLoader);
|
|
358
439
|
await expect(
|
|
359
|
-
enforcingEntityLoader.loadManyByRawWhereClauseAsync(anything(), anything(), anything())
|
|
440
|
+
enforcingEntityLoader.loadManyByRawWhereClauseAsync(anything(), anything(), anything()),
|
|
360
441
|
).resolves.toEqual([resolved]);
|
|
361
442
|
});
|
|
362
443
|
});
|
|
363
444
|
|
|
364
445
|
it('has the same method names as EntityLoader', () => {
|
|
365
446
|
const enforcingLoaderProperties = Object.getOwnPropertyNames(EnforcingEntityLoader.prototype);
|
|
366
|
-
const
|
|
447
|
+
const nonEnforcingLoaderProperties = Object.getOwnPropertyNames(
|
|
448
|
+
AuthorizationResultBasedEntityLoader.prototype,
|
|
449
|
+
);
|
|
367
450
|
|
|
368
451
|
// ensure known differences still exist for sanity check
|
|
369
|
-
const knownLoaderOnlyDifferences = [
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
'tryConstructEntities',
|
|
374
|
-
'validateFieldValues',
|
|
375
|
-
'constructAndAuthorizeEntitiesAsync',
|
|
376
|
-
'constructEntity',
|
|
377
|
-
];
|
|
378
|
-
expect(loaderProperties).toEqual(expect.arrayContaining(knownLoaderOnlyDifferences));
|
|
452
|
+
const knownLoaderOnlyDifferences = ['validateFieldValues'];
|
|
453
|
+
expect(nonEnforcingLoaderProperties).toEqual(
|
|
454
|
+
expect.arrayContaining(knownLoaderOnlyDifferences),
|
|
455
|
+
);
|
|
379
456
|
|
|
380
|
-
const loaderPropertiesWithoutKnownDifferences =
|
|
381
|
-
(p) => !knownLoaderOnlyDifferences.includes(p)
|
|
457
|
+
const loaderPropertiesWithoutKnownDifferences = nonEnforcingLoaderProperties.filter(
|
|
458
|
+
(p) => !knownLoaderOnlyDifferences.includes(p),
|
|
382
459
|
);
|
|
383
460
|
|
|
384
461
|
expect(enforcingLoaderProperties).toEqual(loaderPropertiesWithoutKnownDifferences);
|