@prisma/language-server
Version:
Prisma Language Server
123 lines • 4.18 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const MessageHandler_1 = require("../lib/MessageHandler");
const MultifileHelper_1 = require("./MultifileHelper");
(0, vitest_1.describe)('hover', () => {
(0, vitest_1.test)('model doc from field', async () => {
const helper = await (0, MultifileHelper_1.getMultifileHelper)('user-posts');
const user = helper.file('User.prisma');
const response = (0, MessageHandler_1.handleHoverRequest)(helper.schema, user.textDocument, {
textDocument: {
uri: user.uri,
},
position: user.lineContaining('posts Post[]').characterAfter('Po'),
});
(0, vitest_1.expect)(response).toMatchInlineSnapshot(`
{
"contents": {
"kind": "markdown",
"value": "\`\`\`prisma
model Post {
...
author User @relation(name: "PostToUser", fields: [authorId], references: [id])
}
\`\`\`
___
one-to-many
___
This is a blog post",
},
}
`);
});
(0, vitest_1.test)('enum doc from field', async () => {
const helper = await (0, MultifileHelper_1.getMultifileHelper)('user-posts');
const user = helper.file('User.prisma');
const response = (0, MessageHandler_1.handleHoverRequest)(helper.schema, user.textDocument, {
textDocument: {
uri: user.uri,
},
position: user.lineContaining('favouriteAnimal FavouriteAnimal').characterAfter('Favo'),
});
(0, vitest_1.expect)(response).toMatchInlineSnapshot(`
{
"contents": {
"kind": "markdown",
"value": "\`\`\`prisma
enum FavouriteAnimal {}
\`\`\`
___
My favourite is the red panda, could you tell?",
},
}
`);
});
(0, vitest_1.test)('composite doc from field', async () => {
const helper = await (0, MultifileHelper_1.getMultifileHelper)('user-posts');
const user = helper.file('User.prisma');
const response = (0, MessageHandler_1.handleHoverRequest)(helper.schema, user.textDocument, {
textDocument: {
uri: user.uri,
},
position: user.lineContaining('address Address').characterAfter('Addr'),
});
(0, vitest_1.expect)(response).toMatchInlineSnapshot(`
{
"contents": {
"kind": "markdown",
"value": "\`\`\`prisma
type Address {}
\`\`\`
___
Petrichor V",
},
}
`);
});
(0, vitest_1.test)('doc from block name', async () => {
const helper = await (0, MultifileHelper_1.getMultifileHelper)('user-posts');
const user = helper.file('animal.prisma');
const response = (0, MessageHandler_1.handleHoverRequest)(helper.schema, user.textDocument, {
textDocument: {
uri: user.uri,
},
position: user.lineContaining('enum FavouriteAnimal {').characterAfter('Fav'),
});
(0, vitest_1.expect)(response).toMatchInlineSnapshot(`
{
"contents": {
"kind": "markdown",
"value": "\`\`\`prisma
enum FavouriteAnimal {}
\`\`\`
___
My favourite is the red panda, could you tell?",
},
}
`);
});
(0, vitest_1.test)('doc from field name', async () => {
const helper = await (0, MultifileHelper_1.getMultifileHelper)('user-posts');
const user = helper.file('address.prisma');
const response = (0, MessageHandler_1.handleHoverRequest)(helper.schema, user.textDocument, {
textDocument: {
uri: user.uri,
},
position: user.lineContaining('country String').characterAfter('cou'),
});
(0, vitest_1.expect)(response).toMatchInlineSnapshot(`
{
"contents": {
"kind": "markdown",
"value": "\`\`\`prisma
country
\`\`\`
___
ISO 3166-2 standard",
},
}
`);
});
});
//# sourceMappingURL=hover.test.js.map