From 4437af94a84dca1c19aa09bb9676af60769a5c47 Mon Sep 17 00:00:00 2001 From: Arjunlal B Date: Thu, 21 Sep 2023 15:00:01 -0700 Subject: [PATCH] fix: mock preferences in explorer test --- .../src/pages/explorer/explorer.component.test.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/projects/observability/src/pages/explorer/explorer.component.test.ts b/projects/observability/src/pages/explorer/explorer.component.test.ts index 90c92b25b..9922ca470 100644 --- a/projects/observability/src/pages/explorer/explorer.component.test.ts +++ b/projects/observability/src/pages/explorer/explorer.component.test.ts @@ -11,7 +11,9 @@ import { LayoutChangeService, NavigationService, PreferenceService, + PreferenceValue, RelativeTimeRange, + StorageType, TimeDuration, TimeRangeService, TimeUnit @@ -71,6 +73,7 @@ describe('Explorer component', () => { const testTimeRange = new RelativeTimeRange(new TimeDuration(15, TimeUnit.Minute)); const createComponent = createComponentFactory({ component: ExplorerComponent, + shallow: true, imports: [ ExplorerModule.withDashboardBuilderFactory({ useFactory: (metadataService: MetadataService, filterBuilderLookupService: FilterBuilderLookupService) => @@ -111,7 +114,10 @@ describe('Explorer component', () => { } }, mockProvider(PreferenceService, { - get: jest.fn().mockReturnValue(of(true)) + get: jest.fn().mockReturnValue(of(true)), + getOnce: jest + .fn() + .mockImplementation((_key: string, defaultValue: PreferenceValue, _storageType: StorageType) => defaultValue) }), ...getMockFlexLayoutProviders() ]