Skip to content

Commit

Permalink
Improve tests and ts docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-McFarlin committed Jun 11, 2024
1 parent c483e0b commit 97ef6f1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/entity/src/EntityCompanion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ReadonlyEntity from './ReadonlyEntity';
import ViewerContext from './ViewerContext';
import EntityTableDataCoordinator from './internal/EntityTableDataCoordinator';
import IEntityMetricsAdapter from './metrics/IEntityMetricsAdapter';
import { mergeEntityMutationTriggerConfigurations } from './utils/mergeMutationTriggers';
import { mergeEntityMutationTriggerConfigurations } from './utils/mergeEntityMutationTriggerConfigurations';

export interface IPrivacyPolicyClass<TPrivacyPolicy> {
new (): TPrivacyPolicy;
Expand Down
2 changes: 1 addition & 1 deletion packages/entity/src/EntityCompanionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default class EntityCompanionProvider {
* @param metricsAdapter - An IEntityMetricsAdapter for collecting metrics on this instance
* @param databaseAdapterFlavors - Database adapter configurations for this instance
* @param cacheAdapterFlavors - Cache adapter configurations for this instance
* @param globalMutationTriggers - An optional list of EntityMutationTrigger for all entities.
* @param globalMutationTriggers - Optional set of EntityMutationTrigger to run for all entity mutations systemwide.
*/
constructor(
public readonly metricsAdapter: IEntityMetricsAdapter,
Expand Down
10 changes: 5 additions & 5 deletions packages/entity/src/__tests__/EntityCompanion-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ describe(EntityCompanion, () => {
const localTriggers = companion.entityCompanionDefinition.mutationTriggers;
expect(localTriggers).toBeTruthy();

expect(mergedTriggers.afterCreate![0]).toBe(localTriggers!.afterCreate![0]);
expect(mergedTriggers.afterCreate![1]).toBe(globalMutationTriggers.afterCreate![0]);
expect(mergedTriggers.afterAll![0]).toBe(localTriggers!.afterAll![0]);
expect(mergedTriggers.afterAll![1]).toBe(globalMutationTriggers!.afterAll![0]);
expect(mergedTriggers.afterCommit![0]).toBe(localTriggers!.afterCommit![0]);
expect(mergedTriggers).toStrictEqual({
afterCreate: [localTriggers!.afterCreate![0], globalMutationTriggers.afterCreate![0]],
afterAll: [localTriggers!.afterAll![0], globalMutationTriggers!.afterAll![0]],
afterCommit: [localTriggers!.afterCommit![0]],
});
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TestMutationTrigger } from '../../testfixtures/TestEntityWithMutationTriggers';
import { mergeEntityMutationTriggerConfigurations } from '../mergeMutationTriggers';
import { mergeEntityMutationTriggerConfigurations } from '../mergeEntityMutationTriggerConfigurations';

describe(mergeEntityMutationTriggerConfigurations, () => {
it('successfully merges triggers', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function mergeEntityMutationTriggerConfigurations<

/** Remove any trigger that is an empty array */
for (const key of Object.keys(merged) as (keyof typeof merged)[]) {
if (!merged[key]?.length) {
if (merged[key].length === 0) {
delete merged[key];
}
}
Expand Down

0 comments on commit 97ef6f1

Please sign in to comment.