diff --git a/helpers/functions.cache.d.ts b/helpers/functions.cache.d.ts index fd037a8d..b88b3c11 100644 --- a/helpers/functions.cache.d.ts +++ b/helpers/functions.cache.d.ts @@ -19,4 +19,5 @@ export declare function getWorkOrderMilestoneTypes(): Promise; export declare function getWorkOrderMilestoneTypeByWorkOrderMilestoneType(workOrderMilestoneTypeString: string): Promise; export declare function preloadCaches(): Promise; +export declare function clearCaches(): void; export declare function clearCacheByTableName(tableName: string, relayMessage?: boolean): void; diff --git a/helpers/functions.cache.js b/helpers/functions.cache.js index 585cc1b5..37216e8d 100644 --- a/helpers/functions.cache.js +++ b/helpers/functions.cache.js @@ -169,6 +169,14 @@ export async function preloadCaches() { await getWorkOrderTypes(); await getWorkOrderMilestoneTypes(); } +export function clearCaches() { + clearLotOccupantTypesCache(); + clearLotStatusesCache(); + clearLotTypesCache(); + clearOccupancyTypesCache(); + clearWorkOrderTypesCache(); + clearWorkOrderMilestoneTypesCache(); +} function clearWorkOrderMilestoneTypesCache() { workOrderMilestoneTypes = undefined; } diff --git a/helpers/functions.cache.ts b/helpers/functions.cache.ts index 7f339d37..f16472b7 100644 --- a/helpers/functions.cache.ts +++ b/helpers/functions.cache.ts @@ -308,6 +308,15 @@ export async function preloadCaches(): Promise { await getWorkOrderMilestoneTypes() } +export function clearCaches(): void { + clearLotOccupantTypesCache() + clearLotStatusesCache() + clearLotTypesCache() + clearOccupancyTypesCache() + clearWorkOrderTypesCache() + clearWorkOrderMilestoneTypesCache() +} + function clearWorkOrderMilestoneTypesCache(): void { workOrderMilestoneTypes = undefined } diff --git a/test/functions.js b/test/functions.js index 4f4fbcf8..7ec75957 100644 --- a/test/functions.js +++ b/test/functions.js @@ -16,6 +16,9 @@ describe('config.cemetery.ssm', () => { describe('functions.cache', () => { const badId = -3; const badName = 'qwertyuiopasdfghjklzxcvbnm'; + before(() => { + cacheFunctions.clearCaches(); + }); describe('Lot Occupant Types', () => { it('returns Lot Occupant Types', async () => { cacheFunctions.clearCacheByTableName('LotOccupantTypes'); diff --git a/test/functions.ts b/test/functions.ts index c06186ac..87098b91 100644 --- a/test/functions.ts +++ b/test/functions.ts @@ -25,6 +25,10 @@ describe('functions.cache', () => { const badId = -3 const badName = 'qwertyuiopasdfghjklzxcvbnm' + before(() => { + cacheFunctions.clearCaches() + }) + describe('Lot Occupant Types', () => { it('returns Lot Occupant Types', async () => { cacheFunctions.clearCacheByTableName('LotOccupantTypes')