diff options
Diffstat (limited to 'src/pybind/mgr/dashboard/frontend/src/app/shared/components/sparkline/sparkline.component.spec.ts')
-rw-r--r-- | src/pybind/mgr/dashboard/frontend/src/app/shared/components/sparkline/sparkline.component.spec.ts | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/sparkline/sparkline.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/sparkline/sparkline.component.spec.ts index b8e731d6e..27d170190 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/sparkline/sparkline.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/sparkline/sparkline.component.spec.ts @@ -5,6 +5,7 @@ import { DimlessBinaryPipe } from '~/app/shared/pipes/dimless-binary.pipe'; import { FormatterService } from '~/app/shared/services/formatter.service'; import { configureTestBed } from '~/testing/unit-test-helper'; import { SparklineComponent } from './sparkline.component'; +import { ResizeObserver as ResizeObserverPolyfill } from '@juggle/resize-observer'; describe('SparklineComponent', () => { let component: SparklineComponent; @@ -19,34 +20,37 @@ describe('SparklineComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(SparklineComponent); component = fixture.componentInstance; + if (typeof window !== 'undefined') { + window.ResizeObserver = window.ResizeObserver || ResizeObserverPolyfill; + } fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); - expect(component.options.tooltips.custom).toBeDefined(); + expect(component.options.plugins.tooltip.external).toBeDefined(); }); it('should update', () => { - expect(component.datasets).toEqual([{ data: [] }]); - expect(component.labels.length).toBe(0); + expect(component.datasets[0].data).toEqual([]); + expect(component.chartData.labels.length).toBe(0); component.data = [11, 22, 33]; component.ngOnChanges({ data: new SimpleChange(null, component.data, false) }); - expect(component.datasets).toEqual([{ data: [11, 22, 33] }]); - expect(component.labels.length).toBe(3); + expect(component.datasets[0].data).toEqual([11, 22, 33]); + expect(component.chartData.labels.length).toBe(3); }); it('should not transform the label, if not isBinary', () => { component.isBinary = false; - const result = component.options.tooltips.callbacks.label({ yLabel: 1024 }); + const result = component.options.plugins.tooltip.callbacks.label({ parsed: { y: 1024 } }); expect(result).toBe(1024); }); it('should transform the label, if isBinary', () => { component.isBinary = true; - const result = component.options.tooltips.callbacks.label({ yLabel: 1024 }); + const result = component.options.plugins.tooltip.callbacks.label({ parsed: { y: 1024 } }); expect(result).toBe('1 KiB'); }); }); |