|
| 1 | +import { test } from 'vitest' |
| 2 | +import * as path from 'node:path' |
| 3 | +import { withFixture, withWorkspace } from '../common' |
| 4 | +import { DidChangeWorkspaceFoldersNotification, HoverRequest } from 'vscode-languageserver' |
| 5 | + |
| 6 | +withFixture('document-selection/basic', (c) => { |
| 7 | + test('basic: should provide hovers', async ({ expect }) => { |
| 8 | + let textDocument = await c.openDocument({ |
| 9 | + text: '<div class="bg-[#000]">', |
| 10 | + }) |
| 11 | + |
| 12 | + let res = await c.sendRequest(HoverRequest.type, { |
| 13 | + textDocument, |
| 14 | + position: { line: 0, character: 13 }, |
| 15 | + }) |
| 16 | + |
| 17 | + expect(res).toEqual({ |
| 18 | + contents: { |
| 19 | + language: 'css', |
| 20 | + value: |
| 21 | + '.bg-\\[\\#000\\] {\n --tw-bg-opacity: 1;\n background-color: rgb(0 0 0 / var(--tw-bg-opacity)) /* #000000 */;\n}', |
| 22 | + }, |
| 23 | + range: { start: { line: 0, character: 12 }, end: { line: 0, character: 21 } }, |
| 24 | + }) |
| 25 | + }) |
| 26 | +}) |
| 27 | + |
| 28 | +withFixture('document-selection/(parens)', (c) => { |
| 29 | + test('parens: should provide hovers', async ({ expect }) => { |
| 30 | + let textDocument = await c.openDocument({ |
| 31 | + text: '<div class="bg-[#000]">', |
| 32 | + }) |
| 33 | + |
| 34 | + let res = await c.sendRequest(HoverRequest.type, { |
| 35 | + textDocument, |
| 36 | + position: { line: 0, character: 13 }, |
| 37 | + }) |
| 38 | + |
| 39 | + expect(res).toEqual({ |
| 40 | + contents: { |
| 41 | + language: 'css', |
| 42 | + value: |
| 43 | + '.bg-\\[\\#000\\] {\n --tw-bg-opacity: 1;\n background-color: rgb(0 0 0 / var(--tw-bg-opacity)) /* #000000 */;\n}', |
| 44 | + }, |
| 45 | + range: { start: { line: 0, character: 12 }, end: { line: 0, character: 21 } }, |
| 46 | + }) |
| 47 | + }) |
| 48 | +}) |
| 49 | + |
| 50 | +withFixture('document-selection/[brackets]', (c) => { |
| 51 | + test('brackets: should provide hovers', async ({ expect }) => { |
| 52 | + let textDocument = await c.openDocument({ |
| 53 | + text: '<div class="bg-[#000]">', |
| 54 | + }) |
| 55 | + |
| 56 | + let res = await c.sendRequest(HoverRequest.type, { |
| 57 | + textDocument, |
| 58 | + position: { line: 0, character: 13 }, |
| 59 | + }) |
| 60 | + |
| 61 | + expect(res).toEqual({ |
| 62 | + contents: { |
| 63 | + language: 'css', |
| 64 | + value: |
| 65 | + '.bg-\\[\\#000\\] {\n --tw-bg-opacity: 1;\n background-color: rgb(0 0 0 / var(--tw-bg-opacity)) /* #000000 */;\n}', |
| 66 | + }, |
| 67 | + range: { start: { line: 0, character: 12 }, end: { line: 0, character: 21 } }, |
| 68 | + }) |
| 69 | + }) |
| 70 | +}) |
| 71 | + |
| 72 | +withFixture('document-selection/{curlies}', (c) => { |
| 73 | + test('curlies: should provide hovers', async ({ expect }) => { |
| 74 | + let textDocument = await c.openDocument({ |
| 75 | + text: '<div class="bg-[#000]">', |
| 76 | + }) |
| 77 | + |
| 78 | + let res = await c.sendRequest(HoverRequest.type, { |
| 79 | + textDocument, |
| 80 | + position: { line: 0, character: 13 }, |
| 81 | + }) |
| 82 | + |
| 83 | + expect(res).toEqual({ |
| 84 | + contents: { |
| 85 | + language: 'css', |
| 86 | + value: |
| 87 | + '.bg-\\[\\#000\\] {\n --tw-bg-opacity: 1;\n background-color: rgb(0 0 0 / var(--tw-bg-opacity)) /* #000000 */;\n}', |
| 88 | + }, |
| 89 | + range: { start: { line: 0, character: 12 }, end: { line: 0, character: 21 } }, |
| 90 | + }) |
| 91 | + }) |
| 92 | +}) |
0 commit comments