diff --git a/packages/grafana-ui/src/components/Chart/Tooltip.test.tsx b/packages/grafana-ui/src/components/Chart/Tooltip.test.tsx deleted file mode 100644 index 2162c3f82ac..00000000000 --- a/packages/grafana-ui/src/components/Chart/Tooltip.test.tsx +++ /dev/null @@ -1,100 +0,0 @@ -import React from 'react'; -import { mount } from 'enzyme'; -import { Tooltip } from './Tooltip'; - -// Tooltip container has padding of 8px, let's assume target tooltip has measured width & height of 100px -const content =
; - -describe('Chart Tooltip', () => { - describe('is positioned correctly', () => { - beforeEach(() => { - // jsdom does not perform actual DOM rendering - // We need to mock getBoundingClientRect to return what DOM would actually return - // when measuring tooltip container (wrapper with padding and content inside) - Element.prototype.getBoundingClientRect = jest.fn(() => { - return { width: 100, height: 100, top: 0, left: 0, bottom: 0, right: 0 } as DOMRect; - }); - }); - - // Jest's default viewport size is 1024x768px - test('when fits into the viewport', () => { - const tooltip = mount(); - const container = tooltip.find('TooltipContainer > div'); - const styleAttribute = container.getDOMNode().getAttribute('style'); - - // +------+ - // |origin| - // +------+--------------+ - // | Tooltip | - // | | - // +--------------+ - expect(styleAttribute).toContain('translate3d(0px, 0px, 0)'); - }); - - test("when overflows viewport's x axis", () => { - const tooltip = mount(); - const container = tooltip.find('TooltipContainer > div'); - const styleAttribute = container.getDOMNode().getAttribute('style'); - - // We expect tooltip to flip over left side of the origin position - // +------+ - // |origin| - // +--------------+------+ - // | Tooltip | - // | | - // +--------------+ - expect(styleAttribute).toContain('translate3d(900px, 0px, 0)'); - }); - - test("when overflows viewport's y axis", () => { - const tooltip = mount(); - const container = tooltip.find('TooltipContainer > div'); - const styleAttribute = container.getDOMNode().getAttribute('style'); - - // We expect tooltip to flip over top side of the origin position - // +--------------+ - // | Tooltip | - // | | - // +------+--------------+ - // |origin| - // +------+ - expect(styleAttribute).toContain('translate3d(0px, 600px, 0)'); - }); - - test("when overflows viewport's x and y axes", () => { - const tooltip = mount(); - const container = tooltip.find('TooltipContainer > div'); - const styleAttribute = container.getDOMNode().getAttribute('style'); - - // We expect tooltip to flip over the left top corner of the origin position - // +--------------+ - // | Tooltip | - // | | - // +--------------+------+ - // |origin| - // +------+ - expect(styleAttribute).toContain('translate3d(900px, 600px, 0)'); - }); - - describe('when offset provided', () => { - test("when overflows viewport's x and y axes", () => { - const tooltip = mount(); - const container = tooltip.find('TooltipContainer > div'); - const styleAttribute = container.getDOMNode().getAttribute('style'); - - // We expect tooltip to flip over the left top corner of the origin position with offset applied - // +--------------------+ - // | | - // | +--------------+ | - // | | Tooltip | | - // | | | | - // | +--------------+ | - // | offset| - // +--------------------++------+ - // |origin| - // +------+ - expect(styleAttribute).toContain('translate3d(910px, 610px, 0)'); - }); - }); - }); -}); diff --git a/packages/grafana-ui/src/components/Graph/Graph.test.tsx b/packages/grafana-ui/src/components/Graph/Graph.test.tsx index af05b7eae58..08e0df14968 100644 --- a/packages/grafana-ui/src/components/Graph/Graph.test.tsx +++ b/packages/grafana-ui/src/components/Graph/Graph.test.tsx @@ -79,6 +79,13 @@ const mockGraphProps = (multiSeries = false) => { timeZone: 'browser', }; }; + +(window as any).ResizeObserver = class ResizeObserver { + constructor() {} + observe() {} + disconnect() {} +}; + describe('Graph', () => { describe('with tooltip', () => { describe('in single mode', () => {