Visual Studio Code, rebuilt in Rust
Rust
import { expect, test } from 'bun:test';
import { completions, hover } from './lib.js';
test('directive names at the start of a line, sections after <', () => {
const directives = completions(' Direc')!;
expect(directives.word).toBe('Direc');
expect(directives.items.find(item => item.label === 'DirectoryIndex')?.snippet).toBe('DirectoryIndex ');
expect(directives.items.some(item => item.label === 'Directory')).toBe(false);
const sections = completions('<Vir')!;
expect(sections.items.find(item => item.label === 'VirtualHost')?.snippet).toBe('VirtualHost ${1:addr[:port] [addr[:port]] ...}>\n\t$0\n</VirtualHost>');
expect(sections.items.find(item => item.label === 'Else')?.snippet).toBe('Else>\n\t$0\n</Else>');
expect(completions('</')!.items.find(item => item.label === 'Directory')?.snippet).toBe('Directory>');
});
test('no completions after the directive name', () => {
expect(completions('DirectoryIndex ind')).toBeUndefined();
});
test('the hover of a directive name, not of an argument', () => {
const line = '<Directory /var/www>';
expect(hover(line, 1, 10)).toContain('Module: [core](https://httpd.apache.org/docs/2.4/mod/core.html#directory)');
expect(hover('options Indexes', 0, 7)).toContain('Context: server config, virtual host, directory, .htaccess');
expect(hover('Options Indexes', 8, 15)).toBeUndefined();
});