Skip to content

Commit

Permalink
test: adjust tooltip tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgrozav committed Nov 27, 2024
1 parent a04dcae commit 7389737
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import CanvasNodeTooltip from './CanvasNodeTooltip.vue';
import { createComponentRenderer } from '@/__tests__/render';
import type { CanvasNodeDefaultRender } from '@/types';
import { createCanvasNodeProvide } from '@/__tests__/data';
import { waitFor } from '@testing-library/vue';

const renderComponent = createComponentRenderer(CanvasNodeTooltip);

describe('CanvasNodeTooltip', () => {
describe('rendering', () => {
it('should render tooltip when tooltip option is provided', () => {
const { getByText } = renderComponent({
it('should render tooltip when tooltip option is provided', async () => {
const { container, getByText } = renderComponent({
props: {
visible: true,
},
Expand All @@ -26,25 +27,28 @@ describe('CanvasNodeTooltip', () => {
});

expect(getByText('Test tooltip text')).toBeInTheDocument();
await waitFor(() => expect(container.querySelector('.el-popper')).toBeVisible());
});

it('should not render tooltip when tooltip option is not provided', () => {
const { container } = renderComponent({
props: {
visible: true,
visible: false,
},
global: {
provide: createCanvasNodeProvide({
data: {
render: {
options: {},
options: {
tooltip: 'Test tooltip text',
},
} as CanvasNodeDefaultRender,
},
}),
},
});

expect(container.querySelector('.tooltipTrigger')).not.toBeInTheDocument();
expect(container.querySelector('.el-popper')).not.toBeVisible();
});
});
});

0 comments on commit 7389737

Please sign in to comment.