Path: blob/main/src/vs/editor/contrib/hover/test/browser/contentHover.test.ts
5313 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import assert from 'assert';6import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/test/common/utils.js';7import { Position } from '../../../../common/core/position.js';8import { Range } from '../../../../common/core/range.js';9import { RenderedContentHover } from '../../browser/contentHoverRendered.js';10import { IHoverPart } from '../../browser/hoverTypes.js';11import { TestCodeEditorInstantiationOptions, withTestCodeEditor } from '../../../../test/browser/testCodeEditor.js';1213suite('Content Hover', () => {1415ensureNoDisposablesAreLeakedInTestSuite();1617test('issue #151235: Gitlens hover shows up in the wrong place', () => {18const text = 'just some text';19withTestCodeEditor(text, {}, (editor) => {20const actual = RenderedContentHover.computeHoverPositions(21editor,22new Range(5, 5, 5, 5),23[<IHoverPart>{ range: new Range(4, 1, 5, 6) }]24);25assert.deepStrictEqual(26actual,27{28showAtPosition: new Position(5, 5),29showAtSecondaryPosition: new Position(5, 5)30}31);32});33});3435test('issue #95328: Hover placement with word-wrap', () => {36const text = 'just some text';37const opts: TestCodeEditorInstantiationOptions = { wordWrap: 'wordWrapColumn', wordWrapColumn: 6 };38withTestCodeEditor(text, opts, (editor) => {39const actual = RenderedContentHover.computeHoverPositions(40editor,41new Range(1, 8, 1, 8),42[<IHoverPart>{ range: new Range(1, 1, 1, 15) }]43);44assert.deepStrictEqual(45actual,46{47showAtPosition: new Position(1, 8),48showAtSecondaryPosition: new Position(1, 6)49}50);51});52});53});545556