-
-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`Completions > #2454 1`] = ` | ||
" | ||
<script setup lang="ts"> | ||
let vLoading: any; | ||
</script> | ||
<template> | ||
<div v-loading="vLoading"></div> | ||
</template> | ||
" | ||
`; | ||
|
||
exports[`Completions > #2511 1`] = ` | ||
" | ||
<script setup lang="ts"> | ||
import componentForAutoImport$1 from './component-for-auto-import.vue'; | ||
</script> | ||
" | ||
`; | ||
|
||
exports[`Completions > #3658 1`] = ` | ||
" | ||
<template> | ||
<Comp> | ||
<template #foo="foo"> | ||
{{ foo }} | ||
</template> | ||
</Comp> | ||
</template> | ||
" | ||
`; | ||
exports[`Completions > #4639 1`] = ` | ||
" | ||
<template> | ||
<div @click.capture /> | ||
</template> | ||
" | ||
`; | ||
exports[`Completions > $event argument 1`] = `"<template><div @click="console.log($event)"></div></template>"`; | ||
exports[`Completions > <script setup> 1`] = ` | ||
" | ||
<template>{{ foo }}</template> | ||
<script lang="ts" setup> | ||
const foo = 1; | ||
</script> | ||
" | ||
`; | ||
exports[`Completions > Alias path 1`] = ` | ||
" | ||
<script setup lang="ts"> | ||
import Component from '@/empty.vue'; | ||
</script> | ||
" | ||
`; | ||
exports[`Completions > Component auto import 1`] = ` | ||
" | ||
<script setup lang="ts"> | ||
import ComponentForAutoImport from './ComponentForAutoImport.vue'; | ||
</script> | ||
<template> | ||
<ComponentForAutoImport /> | ||
</template> | ||
" | ||
`; | ||
exports[`Completions > Directives 1`] = `"<template><div v-html="$1"></div></template>"`; | ||
exports[`Completions > Directives 2`] = `"<template><div v-cloak></div></template>"`; | ||
exports[`Completions > Directives 3`] = `"<template><div v-else></div></template>"`; | ||
exports[`Completions > Directives 4`] = `"<template><div v-pre></div></template>"`; | ||
exports[`Completions > Relative path 1`] = ` | ||
" | ||
<script setup lang="ts"> | ||
import Component from './empty.vue'; | ||
</script> | ||
" | ||
`; | ||
exports[`Completions > Slot name 1`] = ` | ||
" | ||
<template> | ||
<Foo> | ||
<template #default></template> | ||
</Foo> | ||
</template> | ||
<script lang="ts" setup> | ||
let Foo: new () => { | ||
$slots: { | ||
default: any; | ||
}; | ||
}; | ||
</script> | ||
" | ||
`; | ||
exports[`Completions > core#8811 1`] = ` | ||
" | ||
<script setup lang="ts"> | ||
declare const Foo: new () => { | ||
$props: { | ||
FooBar: string; | ||
}; | ||
}; | ||
</script> | ||
<template> | ||
<Foo :-foo-bar="$1" ></Foo> | ||
</template> | ||
" | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`Definitions > Default slot 1`] = `"tsconfigProject/foo.vue"`; | ||
|
||
exports[`Definitions > Default slot 2`] = ` | ||
{ | ||
"end": { | ||
"character": 16, | ||
"line": 7, | ||
}, | ||
"start": { | ||
"character": 5, | ||
"line": 7, | ||
}, | ||
} | ||
`; | ||
|
||
exports[`Definitions > Default slot 3`] = `"tsconfigProject/fixture.vue"`; | ||
|
||
exports[`Definitions > Default slot 4`] = ` | ||
{ | ||
"end": { | ||
"character": 9, | ||
"line": 2, | ||
}, | ||
"start": { | ||
"character": 5, | ||
"line": 2, | ||
}, | ||
} | ||
`; | ||
|
||
exports[`Definitions > Named slot 1`] = `"tsconfigProject/foo.vue"`; | ||
|
||
exports[`Definitions > Named slot 2`] = ` | ||
{ | ||
"end": { | ||
"character": 17, | ||
"line": 6, | ||
}, | ||
"start": { | ||
"character": 14, | ||
"line": 6, | ||
}, | ||
} | ||
`; | ||
|
||
exports[`Definitions > Named slot 3`] = `"tsconfigProject/fixture.vue"`; | ||
|
||
exports[`Definitions > Named slot 4`] = ` | ||
{ | ||
"end": { | ||
"character": 19, | ||
"line": 2, | ||
}, | ||
"start": { | ||
"character": 16, | ||
"line": 2, | ||
}, | ||
} | ||
`; | ||
|
||
exports[`Definitions > v-bind shorthand 1`] = `"tsconfigProject/fixture.vue"`; | ||
|
||
exports[`Definitions > v-bind shorthand 2`] = ` | ||
{ | ||
"end": { | ||
"character": 13, | ||
"line": 6, | ||
}, | ||
"start": { | ||
"character": 10, | ||
"line": 6, | ||
}, | ||
} | ||
`; | ||
|
||
exports[`Definitions > v-bind shorthand 3`] = `"tsconfigProject/fixture.vue"`; | ||
|
||
exports[`Definitions > v-bind shorthand 4`] = ` | ||
{ | ||
"end": { | ||
"character": 12, | ||
"line": 2, | ||
}, | ||
"start": { | ||
"character": 9, | ||
"line": 2, | ||
}, | ||
} | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { TextDocument } from '@volar/language-server'; | ||
import * as path from 'path'; | ||
import { afterEach, describe, expect, it } from 'vitest'; | ||
import { URI } from 'vscode-uri'; | ||
import { getLanguageServer, testWorkspacePath } from './server.js'; | ||
|
||
describe('Definitions', async () => { | ||
|
||
it('Default slot', async () => { | ||
await ensureGlobalTypesHolder('tsconfigProject'); | ||
await openDocument('tsconfigProject/foo.vue', 'vue', ` | ||
<script setup lang="ts"> | ||
import Fixture from './fixture.vue'; | ||
</script> | ||
<template> | ||
<Fixture> | ||
<div></div> | ||
</Fixture> | ||
</template> | ||
`); | ||
await assertReferences('tsconfigProject/fixture.vue', 'vue', ` | ||
<template> | ||
<slot|></slot> | ||
</template> | ||
`); | ||
}); | ||
|
||
it('Named slot', async () => { | ||
await ensureGlobalTypesHolder('tsconfigProject'); | ||
await openDocument('tsconfigProject/foo.vue', 'vue', ` | ||
<script setup lang="ts"> | ||
import Fixture from './fixture.vue'; | ||
</script> | ||
<template> | ||
<Fixture #foo></Fixture> | ||
</template> | ||
`); | ||
await assertReferences('tsconfigProject/fixture.vue', 'vue', ` | ||
<template> | ||
<slot name="|foo"></slot> | ||
</template> | ||
`); | ||
}); | ||
|
||
it('v-bind shorthand', async () => { | ||
await ensureGlobalTypesHolder('tsconfigProject'); | ||
await assertReferences('tsconfigProject/fixture.vue', 'vue', ` | ||
<script setup lang="ts"> | ||
const |foo = 1; | ||
</script> | ||
<template> | ||
<Foo :foo></Foo> | ||
</template> | ||
`); | ||
}); | ||
|
||
const openedDocuments: TextDocument[] = []; | ||
|
||
afterEach(async () => { | ||
const server = await getLanguageServer(); | ||
for (const document of openedDocuments) { | ||
await server.closeTextDocument(document.uri); | ||
} | ||
openedDocuments.length = 0; | ||
}); | ||
|
||
/** | ||
* @deprecated Remove this when #4717 fixed. | ||
*/ | ||
async function ensureGlobalTypesHolder(folderName: string) { | ||
const document = await openDocument(`${folderName}/globalTypesHolder.vue`, 'vue', ''); | ||
const server = await getLanguageServer(); | ||
await server.sendDocumentDiagnosticRequest(document.uri); | ||
} | ||
|
||
async function assertReferences(fileName: string, languageId: string, content: string) { | ||
const offset = content.indexOf('|'); | ||
content = content.slice(0, offset) + content.slice(offset + 1); | ||
|
||
const server = await getLanguageServer(); | ||
let document = await openDocument(fileName, languageId, content); | ||
|
||
const position = document.positionAt(offset); | ||
const references = await server.sendReferencesRequest(document.uri, position, { includeDeclaration: false }); | ||
expect(references).toBeDefined(); | ||
expect(references!.length).greaterThan(0); | ||
|
||
for (const loc of references!) { | ||
expect(path.relative(testWorkspacePath, URI.parse(loc.uri).fsPath)).toMatchSnapshot(); | ||
Check failure on line 92 in packages/language-server/tests/references.spec.ts GitHub Actions / build (18, windows-latest)packages/language-server/tests/references.spec.ts > Definitions > Default slot
Check failure on line 92 in packages/language-server/tests/references.spec.ts GitHub Actions / build (18, windows-latest)packages/language-server/tests/references.spec.ts > Definitions > Named slot
Check failure on line 92 in packages/language-server/tests/references.spec.ts GitHub Actions / build (18, windows-latest)packages/language-server/tests/references.spec.ts > Definitions > v-bind shorthand
|
||
expect(loc.range).toMatchSnapshot(); | ||
} | ||
} | ||
|
||
async function openDocument(fileName: string, languageId: string, content: string) { | ||
const server = await getLanguageServer(); | ||
const uri = URI.file(`${testWorkspacePath}/${fileName}`); | ||
const document = await server.openInMemoryDocument(uri.toString(), languageId, content); | ||
if (openedDocuments.every(d => d.uri !== document.uri)) { | ||
openedDocuments.push(document); | ||
} | ||
return document; | ||
} | ||
}); |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.