Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thecrypticace committed Jul 12, 2024
1 parent e92420d commit a6a29da
Showing 1 changed file with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test } from 'vitest'
import { init } from '../common'
import { HoverRequest } from 'vscode-languageserver'
import { CompletionRequest, HoverRequest } from 'vscode-languageserver'

test('Unknown languages do not provide completions', async ({ expect }) => {
let c = await init('basic')
Expand All @@ -16,6 +16,14 @@ test('Unknown languages do not provide completions', async ({ expect }) => {
})

expect(hover).toEqual(null)

let completion = await c.sendRequest(CompletionRequest.type, {
textDocument,
position: { line: 0, character: 13 },
context: { triggerKind: 1 },
})

expect(completion).toBe(null)
})

test('Custom languages may be specified via init options (deprecated)', async ({ expect }) => {
Expand Down Expand Up @@ -43,6 +51,14 @@ test('Custom languages may be specified via init options (deprecated)', async ({
},
range: { start: { line: 0, character: 12 }, end: { line: 0, character: 21 } },
})

let completion = await c.sendRequest(CompletionRequest.type, {
textDocument,
position: { line: 0, character: 13 },
context: { triggerKind: 1 },
})

expect(completion.items.length).toBe(11509)
})

test('Custom languages may be specified via settings', async ({ expect }) => {
Expand Down Expand Up @@ -74,6 +90,14 @@ test('Custom languages may be specified via settings', async ({ expect }) => {
},
range: { start: { line: 0, character: 12 }, end: { line: 0, character: 21 } },
})

let completion = await c.sendRequest(CompletionRequest.type, {
textDocument,
position: { line: 0, character: 13 },
context: { triggerKind: 1 },
})

expect(completion.items.length).toBe(11509)
})

test('Custom languages are merged from init options and settings', async ({ expect }) => {
Expand Down Expand Up @@ -101,6 +125,12 @@ test('Custom languages are merged from init options and settings', async ({ expe
position: { line: 0, character: 13 },
})

let completion = await c.sendRequest(CompletionRequest.type, {
textDocument,
position: { line: 0, character: 13 },
context: { triggerKind: 1 },
})

textDocument = await c.openDocument({
lang: 'other-lang',
text: '<div class="bg-[#000]">',
Expand All @@ -111,6 +141,12 @@ test('Custom languages are merged from init options and settings', async ({ expe
position: { line: 0, character: 13 },
})

let completion2 = await c.sendRequest(CompletionRequest.type, {
textDocument,
position: { line: 0, character: 13 },
context: { triggerKind: 1 },
})

expect(hover).toEqual({
contents: {
language: 'css',
Expand All @@ -128,6 +164,9 @@ test('Custom languages are merged from init options and settings', async ({ expe
},
range: { start: { line: 0, character: 12 }, end: { line: 0, character: 21 } },
})

expect(completion.items.length).toBe(11509)
expect(completion2.items.length).toBe(11509)
})

test('Language mappings from settings take precedence', async ({ expect }) => {
Expand Down Expand Up @@ -163,4 +202,12 @@ test('Language mappings from settings take precedence', async ({ expect }) => {
},
range: { start: { line: 0, character: 12 }, end: { line: 0, character: 21 } },
})

let completion = await c.sendRequest(CompletionRequest.type, {
textDocument,
position: { line: 0, character: 13 },
context: { triggerKind: 1 },
})

expect(completion.items.length).toBe(11509)
})

0 comments on commit a6a29da

Please sign in to comment.